zynexis Posted November 2, 2022 Posted November 2, 2022 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 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! Quote
Dan C Posted November 2, 2022 Posted November 2, 2022 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! 2022-10-27 09-56-28.mp4 Rasterisation.afmacros Quote
zynexis Posted November 3, 2022 Author Posted November 3, 2022 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 (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 Quote
Dan C Posted November 3, 2022 Posted November 3, 2022 Thanks for letting me know! I certainly understand that there are workflow improvements here, so I will be sure to log these with our developers for you now - to be considered for a future update Quote
Zimti Posted October 11, 2023 Posted October 11, 2023 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!! Quote
NotMyFault Posted October 11, 2023 Posted October 11, 2023 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. Quote Mac mini M1 A2348 | MBP M3 Windows 11 - AMD Ryzen 9 5900x - 32 GB RAM - Nvidia GTX 1080 LG34WK950U-W, calibrated to DCI-P3 with LG Calibration Studio / Spider 5 | Dell 27“ 4K 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. I use iPad screenshots and videos even in the Desktop section of the forum when I expect no relevant difference.
Zimti Posted October 12, 2023 Posted October 12, 2023 Thank you for your reply! Damn. Then we'll have to try other approaches. Affinity gave us really nice trims compared to photoshop, but maybe converting the affinity file to a psd for export could work. Quote
NotMyFault Posted October 12, 2023 Posted October 12, 2023 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. Quote Mac mini M1 A2348 | MBP M3 Windows 11 - AMD Ryzen 9 5900x - 32 GB RAM - Nvidia GTX 1080 LG34WK950U-W, calibrated to DCI-P3 with LG Calibration Studio / Spider 5 | Dell 27“ 4K 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. I use iPad screenshots and videos even in the Desktop section of the forum when I expect no relevant difference.
NotMyFault Posted October 12, 2023 Posted October 12, 2023 Seems to be the trick of the day. Just recommend it in another post. HCl 1 Quote Mac mini M1 A2348 | MBP M3 Windows 11 - AMD Ryzen 9 5900x - 32 GB RAM - Nvidia GTX 1080 LG34WK950U-W, calibrated to DCI-P3 with LG Calibration Studio / Spider 5 | Dell 27“ 4K 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. I use iPad screenshots and videos even in the Desktop section of the forum when I expect no relevant difference.
Zimti Posted October 13, 2023 Posted October 13, 2023 Haha we actually tried this yesterday as well! Would definitely work! However we also saw that exporting as PSD and then using Photoshop led to the same results and was a bit faster Thanks so much for the help!! Quote
zynexis Posted October 26, 2023 Author Posted October 26, 2023 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 girodimo 1 Quote
girodimo Posted January 26, 2024 Posted January 26, 2024 Thanks for the advice. I really wanted not to use Photoshop but I had to stop wasting time. It's the best solution (in Jan. 2024) for now. Quote
Cayenne1 Posted April 20, 2024 Posted April 20, 2024 I just went through this exercise working on creating png's to generate an mpg via Quicktime Player (Mac). Basically, as most have found out, the Affinity Export Layer "Slices" are trimmed down to the bounds of the objects in each Layer and not to the original document size. The subsequent export files can therefor be all over the map in size. However, if you do a normal export from within the Photo Persona after fiddling with what's visible, the file will be Document size. But that requires manually exporting each Layer. I found a technique on an old post that might work in exporting each Layer as individual files at document size. It did for me. In the "Photo" Persona: 1. On a >>COPY<< of your file, select all the Layers to be exported. 2. Rasterize the Layers as "Pixel" if not already. No need to Trim. 3. Select "Edit > Matte" 4. Set Opacity to 1% with the "Slider". Typing in doesn't work. 5. The Layer view in the Export Persona should now show a full document size icon as well as in the Photo Persona Layer view. Ok, you've just added a document sized 1% transparent matte background to the layers in question. That "may not be an issue", but we can remove them later. In the "Export" Persona: 1. From the Layers tab, select the Layers to export 2. Select the Create Slice button 3. Move to the Slices tab and select those "Slices" to export as files (Make sure the file Preset is what you want, PNG, JPG, etc.) 4. Select the Export Slices button There should now be a file for each selected Layer in the designated directory. Now to bulk remove the Partial Transparent pixels, do the following before editing the exports: In the "Photo" Persona: 1. Open one of the exported slice files. 2. Open the Macro panel. (Window > Macro) 3. Start recording (Red button) 4. Select > Alpha Range > Select Partially Transparent (The 1% transparent layer pixels will be selected) 5. Press "Delete" on your keyboard (The 1% transparent layer pixels will be removed) 6. Stop the Macro recording (the White button) 7. Save the Macro to the Library (the staircase button with a +) 8. Name it such as Remove Partial Alpha 9. Close Macro Panel 10. Select File > New Batch Job 11. Add all the sliced files to the "Process" window with the "Add" button 12. Change the "Output" to a new location if desired (prevent overwrite) 13. Set the "Save as ..." to other than AFPhoto such as "PNG" 14. Select the newly created macro with the "Apply" button 15. Finally Select the "OK" button The end result should be a clean file from each Layer of the the original the same size as the original. Practice on a COPY please. The Edit > Matte is non-reversible in particular (I have not found a way to remove a Matte from a layer.) I hope this process helps until the Affinity folks program it in (don't hold your breath). Quote
David in Яuislip Posted April 25, 2024 Posted April 25, 2024 You can export slices at canvas size with the slice in its proper position by Export as psd then use imagemagick magick input.psd output%d.png Quote Microsoft Windows 11 Home, Intel i7-1360P 2.20 GHz, 32 GB RAM, 1TB SSD, Intel Iris Xe Affinity Photo - 24/05/20, Affinity Publisher - 06/12/20, KTM Superduke - 27/09/10
CreativeNode Posted August 5, 2024 Posted August 5, 2024 Here's another option, specifically for my case. I like the options provided above, and hope I'm not repeating anything. In my case, I have: layers with transparency where each layer's object is smaller than the canvas size I need the full canvas size on export, and each exported file needs to be the same size each layer is custom named, and the resulting exports should be layername.png 1. In the Photo Persona, select the layers you'd like exported. 2. In the Export Persona, in the Layers panel, click Create Slice; in the Slices panel, click Export Slices. 3. In the Photo Persona, open 1 of the newly exported PNG files. Create a macro (View, Studio, Macro) by recording Document, Resize Canvas. Save the macro as "Canvas to 1000 x 1000" (or anything you'd like). Close the image without saving. 4. In the Photo Persona, go to File, New Batch Job. Use Add to add your newly exported files. Under Output, select to Save as PNG. Under Available Macros, select your new "Canvas to 1000 x 1000" macro. Apply. OK. All your PNG files should now be the full canvas size with transparency intact. (AP V1) Quote
Meinona Posted September 27, 2024 Posted September 27, 2024 I need to export 587 layers for a game where each sprite needs to be at a specific place on my 1200x1200 canvas. I can either export the slices and re-position all of them manually in my game engine (inaccurate, insane amount of work) or export each layer to png one by one to not loose the dimensions and positioning. This is crazy in 2024, I've been combing through the forums for the solution and people have been asking for this for almost 10 years now. This is such a standard feature and so common in game art, why is it not there yet?! Really disappointed that I have to go back to Photoshop just because this 1 feature is missing Quote
Recommended Posts
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.