Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Entire image trimmed away #51

Open
ttencate opened this issue Jun 22, 2021 · 4 comments
Open

Entire image trimmed away #51

ttencate opened this issue Jun 22, 2021 · 4 comments

Comments

@ttencate
Copy link

This tool looks just like what I need, but unfortunately I only get empty images out of it. Inspecting the generated JSON reveals that every sprite gets trimmed down to 1x1 pixel:

                {
                    "name": "border_bottom_left",
                    "position": {
                        "x": 0,
                        "y": 0
                    },
                    "dimension": {
                        "w": 256,
                        "h": 256
                    },
                    "trim": {
                        "x": 0,
                        "y": 0,
                        "w": 1,
                        "h": 1
                    }
                },

The test suite doesn't pass for me either. On a fresh clone of master (commit 5815c26838d0847fd8d2b836480000f2dd6f1877):

$ yarn install
...
$ yarn test
yarn run v1.22.10
$ eslint lib test example.js
(node:119533) Warning: Accessing non-existent property 'cat' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
(node:119533) Warning: Accessing non-existent property 'cd' of module exports inside circular dependency
(node:119533) Warning: Accessing non-existent property 'chmod' of module exports inside circular dependency
(node:119533) Warning: Accessing non-existent property 'cp' of module exports inside circular dependency
(node:119533) Warning: Accessing non-existent property 'dirs' of module exports inside circular dependency
(node:119533) Warning: Accessing non-existent property 'pushd' of module exports inside circular dependency
(node:119533) Warning: Accessing non-existent property 'popd' of module exports inside circular dependency
(node:119533) Warning: Accessing non-existent property 'echo' of module exports inside circular dependency
(node:119533) Warning: Accessing non-existent property 'tempdir' of module exports inside circular dependency
(node:119533) Warning: Accessing non-existent property 'pwd' of module exports inside circular dependency
(node:119533) Warning: Accessing non-existent property 'exec' of module exports inside circular dependency
(node:119533) Warning: Accessing non-existent property 'ls' of module exports inside circular dependency
(node:119533) Warning: Accessing non-existent property 'find' of module exports inside circular dependency
(node:119533) Warning: Accessing non-existent property 'grep' of module exports inside circular dependency
(node:119533) Warning: Accessing non-existent property 'head' of module exports inside circular dependency
(node:119533) Warning: Accessing non-existent property 'ln' of module exports inside circular dependency
(node:119533) Warning: Accessing non-existent property 'mkdir' of module exports inside circular dependency
(node:119533) Warning: Accessing non-existent property 'rm' of module exports inside circular dependency
(node:119533) Warning: Accessing non-existent property 'mv' of module exports inside circular dependency
(node:119533) Warning: Accessing non-existent property 'sed' of module exports inside circular dependency
(node:119533) Warning: Accessing non-existent property 'set' of module exports inside circular dependency
(node:119533) Warning: Accessing non-existent property 'sort' of module exports inside circular dependency
(node:119533) Warning: Accessing non-existent property 'tail' of module exports inside circular dependency
(node:119533) Warning: Accessing non-existent property 'test' of module exports inside circular dependency
(node:119533) Warning: Accessing non-existent property 'to' of module exports inside circular dependency
(node:119533) Warning: Accessing non-existent property 'toEnd' of module exports inside circular dependency
(node:119533) Warning: Accessing non-existent property 'touch' of module exports inside circular dependency
(node:119533) Warning: Accessing non-existent property 'uniq' of module exports inside circular dependency
(node:119533) Warning: Accessing non-existent property 'which' of module exports inside circular dependency
$ mocha --recursive test


  Cache
    ✓ calls cacheMiss when called the first time
    ✓ does not call cacheMiss for the second time
    ✓ returns correct value
    ✓ in case of a race condition cacheMiss is not called twice (50ms)

  Config
    groups
      ✓ are returned correctly
      ✓ explicit defaults are correctly applied
      ✓ implicit defaults are correctly applied
    scales
      ✓ are returned correctly
      ✓ defaults correctly
    variations
      ✓ are returned correctly
    loading_stages
      ✓ are returned correctly
      ✓ defaults correctly
    concurrency_limit
      ✓ defaults correctly
      ✓ reads image_processing_concurrency_limit
      ✓ reads concurrency_limit
      ✓ reads IMAGE_PROCESSING_CONCURRENCY env var
    show_progress
      ✓ reads the correct field

  Full run
Using fresh cache for /tmp/pixi-packer/test/tmp/cache.json
Group en_menu
  1 sprites
  web: 1 spritesheets, 1.5 KB total
  web_retina: 1 spritesheets, 1.88 KB total

Group de_menu
  1 sprites
  web: 1 spritesheets, 1.78 KB total
  web_retina: 1 spritesheets, 2.18 KB total

Group menu_background
  1 sprites
  web: 1 spritesheets, 2.57 KB total
  web_retina: 1 spritesheets, 7.48 KB total

Group game
  55 sprites
  web: 2 spritesheets, 235.59 KB total
  web_retina: 7 spritesheets, 540.63 KB total

menu_EN_web: 2 spritesheets, 4.07 KB
game_EN_web: 2 spritesheets, 235.59 KB
menu_DE_web: 2 spritesheets, 4.34 KB
game_DE_web: 2 spritesheets, 235.59 KB
menu_EN_web_retina: 2 spritesheets, 9.36 KB
game_EN_web_retina: 7 spritesheets, 540.63 KB
menu_DE_web_retina: 2 spritesheets, 9.66 KB
game_DE_web_retina: 7 spritesheets, 540.63 KB
    ✓ creates an output directory
    ✓ creates an manifests
    ✓ has the right resolution
    ✓ creates all images

  ImageProcessor
    #trim
      1) works correctly on an image with transparency
      2) works correctly on an image without transparency
    #scale
      ✓ works correctly on images with extreme ratios
    #combine
      ✓ works correctly with png (65ms)
      ✓ works correctly with jpeg (42ms)

  Queue
    ✓ concurrency = 1

  Spritesheet
    ✓ has the correct basename
    #calculateHash
      ✓ stays the same if no change is made
      ✓ changes when path of a rect changes
      ✓ changes when scaledSprites is added
      ✓ changes when extension changes
      ✓ changes when quality changes


  31 passing (4s)
  2 failing

  1) ImageProcessor #trim works correctly on an image with transparency:
     Error: ENOENT: no such file or directory, open '/tmp/pixi-packer/test/tmp/crop_out.png'
  

  2) ImageProcessor #trim works correctly on an image without transparency:
     Error: ENOENT: no such file or directory, open '/tmp/pixi-packer/test/tmp/crop_out.png'
  



error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

It could have something to do with my system (Arch Linux):

$ node --version
v14.16.0
$ yarn --version
1.22.10
$ convert --version
Version: ImageMagick 7.0.11-13 Q16 x86_64 2021-05-17 https://imagemagick.org
Copyright: (C) 1999-2021 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC HDRI Modules OpenMP(4.5) 
Delegates (built-in): bzlib cairo djvu fontconfig freetype heic jbig jng jp2 jpeg lcms lqr ltdl lzma openexr pangocairo png raqm raw rsvg tiff webp wmf x xml zip zlib
@SupremeTechnopriest
Copy link

Same issue for me as well.

@SupremeTechnopriest
Copy link

@gluckgames Any ideas or should I go back to spritesmith?

@SvyatoslavPozhydaev
Copy link

SvyatoslavPozhydaev commented Apr 26, 2023

default config image triming is true https://github.com/gluckgames/pixi-packer/blob/master/lib/config.js#L16

but image triming is broken

set trim to false for group_default

    group_default: {
        trim: false,
        max_width: 500,          // default: 2048
        max_height: 500,         // default: 1024
        oversized_warning: true, // default: false
        padding: 1               // default: 1
    },

@SvyatoslavPozhydaev
Copy link

maybe fix aheckmann/gm#860

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants