Jump to content
You must now use your email address to sign in [click for more info] ×

Export all layers to PNG's at canvas size


Recommended Posts

Hello!

Been trying to figure out how to do this fairly basic operation in Affinity Photo, but no luck - is this not possible?

I have multiple sets of 100-300 layers which varying sized images and need to export all to canvas size (512x512) for AI training set
(each layer needs to be placed differently, zoomed in scaled, rotated etc)

I tried using the 'Export persona' but it doesn't seem to export things like i need, it is also a bit unintuitive way to go start creating slices and then it exports things in all different sizes, not what i would expect at all :S

when you do a regular PNG export, it clips the canvas like you'd expect, why is it different and seemingly not obvious how to do it in the 'Export persona'? I'd think it would have even more advanced options

I'm glad i have beefy cpu, since selecting slices this way is pretty intense and the ui looks a bit nuts with hundreds slices, i don't think this is the best experience for doing things like this, there should be a simple save to png with canvas clipping, it is commonly used

I read about some Clip/Unclip canvas, but when i try that option it seem to undo all the work of doing placement adjustment, and just frames the content inside canvas in some way..how do i cut away all the stuff outside the canvas (which sounds like 'Clip canvas' to me but it's not)

at this stage, all the layers are images, not rasterized - if i try multi select all the layers and select Rasterize, it only affects first layer selected, rest are deselected/ignored :( (why can't we multi-rasterize wonder?)

Hope someone can help, Affinity is great, but i run into problems that is needed for working with things at scale such as this

Cheers! :)

slices.PNG

Link to comment
Share on other sites

  • Staff

Hi @zynexis,

When exporting through the Export Persona, the files generated will always be the same as the slice size (when custom export sizes haven't been manually entered), including the area outside of the canvas- if you want each layer to be exported at the size of the canvas, the slices will need to be made at this size before exporting.

The easiest way to do this is using the 'Rasterise & Trim' functionality in Affinity, which will remove the unwanted areas of the image from outside the canvas. After using this function, the slices will be automatically created at the canvas size and will export without a transparent area around the image.

However, the 'Rasterise & Trim' functionality can only be used on one layer at a time, so I have create a Macro for you, which automatically runs this option and then selects the layer below. This means if you import this Macro in to the Library Studio (View > Studio > Library) and then click the macro, the top layer will be trimmed and the second layer selected. Run the macro again to trim the second layer and select the third etc.

Run this macro multiple times, until all of your layers have been trimmed, then create your slices and export from the Export Persona - the images should now match the size of the canvas.
I've created a quick screen recording of these steps and attached this below, alongside the rasterise and trim macro.

I hope this helps!

Rasterisation.afmacros

Link to comment
Share on other sites

Hey, thanks :)

yes, this was what i ended up using, someone else had also suggested using macros in another post as well, record select next layer + rasterize trim

in the end, turned out there was no other way around that sit and click 821 times on the macro play button xD (i had 821 layers, yes)

i really don't like having to resort to this kind of 'work arounds', because it isn't really automated
also there are some problems with this method, you basically need to do this in another save file, since rasterize and trim is destructive, in case you need to do adjustment you have to do things over again. 

Even after doing the trim, there are still things to watch out for, since you still need to go to export persona, do the slices (which still seemed to not be aligned for some reason even after doing 512x512 trim, and in case there is some empty space in a layer, this gets exported incorrectly, so have to enable the 'Include bleed' option to make sure it is output correctly (i think)

I would like to strongly request a baseline feature to Export layers to Images function, this should be a single action

a Rasterize/Rasterize and Trim function that works on multi selections would also be great, the way it works now seem like a slight bug

Link to comment
Share on other sites

  • 11 months later...

Hey! Is there any update on this :(?

I have an affinity designer file with 80 layers, each containing a small graphic.
When making slices, of course each slice is as big as the graphic. However I need all that transparency around it as well.

As far as I can see I only have two options:
1 Exporting every layer individually (File > Export > Png (Area: Whole document)
2 Making slices. Manually dragging all the slices bigger to match the canvas size (which is 4 clicks per slice) and then exporting

I'm coming over from photoshop and have used this workflow for spritesheets and game graphics and ran into this issue in affinity a lot :/
Basically what I'm used to in Photoshop would be: Export layers as files > keep trim layers unchecked + keep transparency.

Something like "double click on the slice sets it to canvas size" would speed up my process a lot.
And a button where you can set ALL slices to canvas size would be a dream!

Any chance for this happening...? :D

If not, is there anything like "batch processing" that could be combined with "File > export as png > whole document + each layer individually"

Or actions... or scripts... or anything else besides slices :'D

Thanks in advance!!

imageexport.png

Link to comment
Share on other sites

V2 allows to rasterize and trim multiple layers at once which reduces the effort for the case of the OP.

There is still no solution for your case.

 

Mac mini M1 A2348

LG34WK950U-W, calibrated to DCI-P3 with LG Calibration Studio / Spider 5

iPad Air Gen 5 (2022) A2589

Special interest into procedural texture filter, edit alpha channel, RGB/16 and RGB/32 color formats, stacking, finding root causes for misbehaving files, finding creative solutions for unsolvable tasks, finding bugs in Apps.

 

Link to comment
Share on other sites

Maybe a trick.

for every layer, create a rectangle of canvas size (no fill) and nest the graphics as child.

you can then use export persona, create slices from layers. Exported files have canvas size.

Mac mini M1 A2348

LG34WK950U-W, calibrated to DCI-P3 with LG Calibration Studio / Spider 5

iPad Air Gen 5 (2022) A2589

Special interest into procedural texture filter, edit alpha channel, RGB/16 and RGB/32 color formats, stacking, finding root causes for misbehaving files, finding creative solutions for unsolvable tasks, finding bugs in Apps.

 

Link to comment
Share on other sites

6 minutes ago, NotMyFault said:

Maybe a trick.

for every layer, create a rectangle of canvas size (no fill) and nest the graphics as child.

you can then use export persona, create slices from layers. Exported files have canvas size.

You beat me to the punch as this was exactly what I wanted to propose.

 

Win11Pro/64gbRam/RTX3060Ti  +  Win10Home/32gbRam/GTX1050Ti + Win11Home/16gbRam/RTX3050


 

Link to comment
Share on other sites

Seems to be the trick of the day. Just recommend it in another post. 

Mac mini M1 A2348

LG34WK950U-W, calibrated to DCI-P3 with LG Calibration Studio / Spider 5

iPad Air Gen 5 (2022) A2589

Special interest into procedural texture filter, edit alpha channel, RGB/16 and RGB/32 color formats, stacking, finding root causes for misbehaving files, finding creative solutions for unsolvable tasks, finding bugs in Apps.

 

Link to comment
Share on other sites

  • 2 weeks later...

Bumping this thread,

It is an extremely common operation especially for many game developers that work with many image, textures and spritesheets

It should not be a convoluted batch process, or a multistep export / cutout / canvas clipping / macro / layer rasterization procedure

in Affinity, sure maybe you could have it be under batch, but i'd say it's so common it should be a regular menu option,
it should really be a 1-2 click operation

It has been in photoshop for many years and have been used since the dawn of time 

------

Just to add an extra note,

In Affinity Photo, there are some menu options:

Layer -> Rasterize...

and 

Layer -> Rasterize & Trim...

the ... in UI terminology means: There will be more options coming, usually an popup window

but in Affinity photo, the ... means nothing and the operation just runs, without further options

Please try to stick to common UI practices and keep things consistent

 

On 10/12/2023 at 12:27 PM, NotMyFault said:

Maybe a trick.

for every layer, create a rectangle of canvas size (no fill) and nest the graphics as child.

you can then use export persona, create slices from layers. Exported files have canvas size.

Now do this 821 times x)

this seems to be a multiuse trick, whenever dealing with exporting x)

On 10/11/2023 at 6:47 PM, Zimti said:

Basically what I'm used to in Photoshop would be: Export layers as files > keep trim layers unchecked + keep transparency.

We need exactly this, no more no less

Link to comment
Share on other sites

  • 2 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.