Code Monkey home page Code Monkey logo

free-tex-packer-core's People

Contributors

angrymouse avatar ct1994 avatar johuang avatar mayakwd avatar odrick avatar phasereditor2d avatar playtomax-team avatar qtiki avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

free-tex-packer-core's Issues

[Feature request] Keep information about identical images in a resulting json

Please add an option so that identical images are deleted only from the texture, but not from the resulting json file. Duplicate files must link to the same area of texture. This is necessary for the animation where the character can remain motionless for some time.

Пожалуйста добавьте опцию чтобы идентичные изображения удалялись только из текстуры, но не из результирующего json файла. Дублирующиеся файлы должны ссылать на один и тот же участок текстуры. Это необходимо для анимации где персонаж может некоторое время оставаться неподвижным.

output unnecessary multiple spritesheets when using scale

I have come across a issue where the packer does not generate the minimum possible number output spritesheet when exceeding the spritesheet width and height and scale enabled.

when width and height is set to 4096

i should get a single 4096x2048 spritesheet but end up with 2 spritesheet of.
2048x2048
1024x512

it seems like the issue is linked to using the original width and height and not the adjusted width and height using the scale.
@odrick

[Feature request] support Egret2D Engine texture pack

Egret Engine 2D is an H5 game Engine,but it not support texture pack by CLI
{
"file": "{{config.imageName}}",
"frames": {
{{#rects}}
"{{{name}}}": {
"x": {{frame.x}},
"y": {{frame.y}},
"w": {{frame.w}},
"h": {{frame.h}},
"hw": {{frame.hw}},
"hh": {{frame.hh}}
}{{^last}},{{/last}}
{{/rects}}
}
}

Purpose of the `scale` parameter

Currently presence of scale property in configuration - does almost nothing,
The only way how it's using in the code at the moment - it's passing it into exporter template.
In my opinion - it should affect textures scale (resize them) and their positions in the atlas (as it described in readme).

May be I've missed something or it is intended to be so?

[Feature Request] Add a meta field that lists all the created atlas

When multiple output files get generated due to having too many images in your atlas there is no way of knowing how many of them were created.

Maybe a file that tells you how many atlas were created could be useful?

(I would make this an option to always do it (even if only one atlas was created) so from code I can just tell my loader to check one file and load all the things that said file knows: be it one or many atlas.)

anyway, awesome work!

Edit: Maybe a metadata field for that would be simpler and break less stuff?

Edit2: the metafield related_multi_packs could host an array of strings naming all the other files created by the packer. We could inject it into the options object here: https://github.com/odrick/free-tex-packer-core/blob/master/FilesProcessor.js#L27 however I am not sure how this would affect the templating system :S
(It seems that the metafield related_multi_packs is what is used for that in other packers)

Something is broken

I am trying to multipack a set of textures to a nearest low po2 value by adjusting the width and height (currently 1024 and 512 respectively), except this is my output:

gamePacked

My full settings are:

"packer": "OptimalPacker",
"packerMethod": "Automatic",
"width": 1024,
"height": 512,
"fixedSize": false,
"powerOfTwo": true,
"alphaThreshold": 4
"padding": 0,
"extrude": 1,
"allowRotation": true,
"detectIdentical": true,
"allowTrim": true,
"removeFileExtension": true,
"prependFolderName": false,
"textureFormat": "png",
"base64Export": false,
"scale": 1,
"exporter": "JsonHash",
"filter": "none"

My source assets:

wildcollect.zip

Seems like a multipack bug, its creating the second texture on the first

Error argument inside callback

It would be great if end user will have an ability to track packing failure:

const packer = require('free-tex-packer-core');
...
packer(items, options, (result, err) => {
 if (err) { 
    logger.error(err);
    return;
 } 
});

Right now I can't track if packing is finished/failed.

"Invalid size" error thrown before trimming occurs

The attached image has a lot of transparent padding causing it to be larger than options.width & options.height, and the "Invalid size" error is thrown by PackProcessor.

Trimming any transparent pixels should take effect before minWidth and minHeight are calculated.

To Reproduce

Using this image...

await packAsync(
    [{
        path: 'a.png',
        contents: await readFile('a.png')
    }],
    {
        exporter: 'JsonHash',
        textureFormat: 'png',
        textureName: 'a.png',
        width: 2048,
        height: 2048,
        allowTrim: true
    }
);

This produces an Invalid size error.

Note that if you bypass the error by settingoptions.width = 6000 & options.height = 6000 the atlas is packed and the resulting image size is only 112x32 (well within the 2048x2048 limits).

a.png

zero offset when use "Spine" exporter

Spine atlas exporter offset is always 0,0
Offset should be calculated from lower-left corner.
I forked your module and wrote some additional codes.
I hope you helped a little.

exporters/index.js

let tpOffset = {
  x: item.spriteSourceSize.x,
  // *Caculate lower-left corner based offset for TexturePacker .atlas format
  y: item.sourceSize.h - (item.spriteSourceSize.y + item.spriteSourceSize.h)
};
return {
  name: name,
  frame: frame,
  spriteSourceSize: spriteSourceSize,
  sourceSize: sourceSize,
  index: index,
  first: index === 0,
  last: index === data.length - 1,
  rotated: item.rotated,
  trimmed: trimmed,
  // *Added tpOffset value to use inside .mst
  tpOffset: tpOffset,
};

exporters/Spine.mst

offset: {{tpOffset.x}},{{tpOffset.y}}

Add Cocos3d exporter with plist format3

Cocos Creator (AFIK 3.3.0 and 2.4.8) rotates the image by 90deg clockwise with Sharp when generating an atlas:

image While `Jimp.rotate(90)` is counter-clockwise.

Please consider rotating 90deg clockwise when exporting toCocos2d with plist format3.

Here is a proposal of Cocos2d.mst:

{{=<% %>=}}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>frames</key>
    <dict>
      <%#rects%>
      <key><%&name%></key>
      <dict>
        <key>aliases</key>
        <array/>
        <key>spriteOffset</key>
        <string>{<% spriteSourceSize.x | offsetLeft : spriteSourceSize.w : sourceSize.w %>,<% spriteSourceSize.y | offsetRight : spriteSourceSize.h : sourceSize.h %>}</string>
        <key>spriteSize</key>
        <string>{<%spriteSourceSize.w%>,<%spriteSourceSize.h%>}</string>
        <key>spriteSourceSize</key>
        <string>{<%sourceSize.w%>,<%sourceSize.h%>}</string>
        <key>textureRect</key>
        <string>{{<%frame.x%>,<%frame.y%>},{<%frame.w%>,<%frame.h%>}}</string>
        <key>textureRotated</key>
        <<%rotated%>/>
      </dict>
      <%/rects%>
    </dict>
    <key>metadata</key>
    <dict>
      <key>format</key>
      <integer>3</integer>
      <key>pixelFormat</key>
      <string><%config.format%></string>
      <key>premultiplyAlpha</key>
      <false/>
      <key>realTextureFileName</key>
      <string><%config.imageFile%></string>
      <key>size</key>
      <string>{<%config.imageWidth%>,<%config.imageHeight%>}</string>
      <key>textureFileName</key>
      <string><%config.imageName%></string>
    </dict>
  </dict>
</plist>
<%={{ }}=%>

summary

  • Change rotate(90) to rotate(-90) when export for Cocos
  • Maybe add an option rotationDirection into config rotation cw/ccw like CustomExporter
  • Update Cocos2d exporter from plist format2 to format

update:
Here is a PR also fix the rotation issue:

Cocos2d exporter format is not correct

  1. Format version mismatch
    according to https://www.codeandweb.com/blog/2016/01/29/cocos2d-plist-format-explained
    The format in this repo is not v3, but it indicates itself v3.
    Actually it's v2 format. Not sure what it supposed to be.

  2. textureFileName is always empty

      <key>textureFileName</key>
      <string><%config.imageFile%></string>

config.imageFile is not set.
This causes the png of the sprite sheet cannot be found, neither Cocostudio (UI tool) nor cocos2d-x 3.17 library.

  1. My temp workaround:
    <key>metadata</key>
    <dict>
      <key>format</key>
      <integer>2</integer>
      <key>pixelFormat</key>
      <string><%config.format%></string>
      <key>premultiplyAlpha</key>
      <false/>
      <key>realTextureFileName</key>
      <string><%config.imageName%></string>
      <key>size</key>
      <string>{<%config.imageWidth%>,<%config.imageHeight%>}</string>
      <key>textureFileName</key>
      <string><%config.imageName%></string>
    </dict>

[Feature request] Option for Image names to be sorted.

Please add an option to sort the images by names in the array, so that they can be embedded in a animations object before meta object. Like below...

"animations": {
"{{config.imageName}}": [{{#rects}}"{{{name}}}"{{^last}},{{/last}}{{/rects}}]
}

Also maybe in the future you can add animations options created folder wise.
Thank you all for a superb software :)

Need index of {{rects}} for use in 'Custom' exporter

Hello, all. Is it possible for any one of you contributors who understand javascript to add an exportable variable that can be accessed inside of the 'custom' exporter (using mustache)?

I need a numerical index reference for each '{{rects}}' that is process, preferably starting at 1 and not zero. I was trying to do it myself but I have zero clue on how to even install / run the javascript code. Thanks for any help.

[feature request] multi pack

First off, amazing work on this! Its easily the strongest alternative to texture packer i have seen 👍

A feature which I think would be super handy to have on this would be a multi-pack option.

This would mean that multiple textures / jsons would be created if all the images do not fit in the single texture of a defined size.

Cheers!

Packing result is worse when rotation allowed

This PR #6 fixed options not passing through.
However, after allowing rotation, my packing result needs more area. (Can't fit in original constraint size)

I have to manually disable rotation to ensure my result the same as before.

Is this a normal case?

Suggestion: 'Best' Packing Option

Hi,

It would be great if there was an additional packing option, that would automatically choose the best packer and packMethod combinations based on the most optimal expected result. Hence the name 'Best'.

We have found that there is no one combination that works for everything, to find the best combination is a manual process, and since we have 100s of spritesheets being generated the process is tedious. And as source assets changed the same process is repeated.

For our use, the method to determine 'best' would be:

  1. Lowest number of textures
  2. If same number of textures, lowest texture memory (area)

It may take a little longer, but in our case it is part of an automated deployment process so time is less important. If time is a big concern the 'Best' option does not need to be the default

[bug] Export Error: Invalid template

Hi there, i have created a spritesheet and am unable to export it.
image

Settings:
image

The spritesheet was generated from a folder with 3 subfolders
image

I can view the animation cells just fine and play them back as well, just the export is not working.
Tried restarting and re-creating the spritesheet, no luck.

Version 0.6.7

Aside from the export-issue, this tool is really neat!

Best,
David

EDIT: I can export if i select a predefined format. Not sure if it's actually a bug or if I was using incorrect settings, feel free to close if it's the latter or too irrelevant.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.