Jump to content
weheartgames

Exporting retina assets not resulting in even-numbered pixel dimensions

Recommended Posts

I am creating layer-based export slices (in the Export persona, selecting a layer then clicking "Create Slice" at the bottom of the layers palette). When I export retina assets, they often do not have even-numbered pixel dimensions.

 

This is not useful for app or game development, as the @2x graphics need to be exactly double the size of the non-retina graphics. 

 

Is there anyway to force it to export even-numbered pixel dimensions for @2x?

 

Thanks!

-Mike

Share this post


Link to post
Share on other sites

Hi Mike,

 

Welcome to the Forums :)

 

The Export Persona Persona will export depending on the size of the slice. If you have your size not aligned to a whole pixel it will make the exported picture odd. I have tried this at my end and it is working fine. Please could you attach one of your files for me to try and recreate this issue with? Once I have looked at the file I will delete it :)

 

C

Share this post


Link to post
Share on other sites

I guess my thought is that slices should *always* be aligned to a whole pixel (or rather, a whole *point*) so that exported sizes are always accurate.

 

When I select a Layer in the Export Persona and click the "Create Slice" button, it appears to snap to whole points, given the dimensions shown for the slice (see attachment). If those dimensions are capable of decimal points, it should definitely show decimal points. I'm having a hard time imagining anyone wanting that behaviour though.

 

Is there an easy way to adjust a slice's size numerically? The only way I can see is to zoom way in and scale each side it to a point edge. This is tedious enough that I would probably rather use other software... :(

 

And thanks, by the way! This is my first real project with AD, and I'm loving it a lot. Reliably getting assets out of it is pretty critical though! :)

Share this post


Link to post
Share on other sites

Ah, I see what the problem is now. I have my document set up using the Page Preset of "iPad Air (Retina)". I was assuming (hoping) that the pixel snapping for creating slices would snap to points, not to pixels. Is there any way to make it do that?

 

I have a slice that is showing as 43 x 39, but when I export it at 1x, it exports to 21 x 19, and the @2x file is 43 x 39. This doesn't work for me (or any game dev), unfortunately. The files need to be precise multiples of each other to work properly.

Share this post


Link to post
Share on other sites

I just had a thought: If I change my DPI to 72, and recreate my slices with pixel snapping turned on, will this work the way I'm expecting it to? For this project, I only have vector layers, so that would be ok... this time.

Share this post


Link to post
Share on other sites

Sorry for the multiple posts. Changing the DPI of the document seems to mess with the Export Persona's measurements, actually. I'm attaching the file with just the one asset in it. This layer was created BEFORE changing the DPI.

 

If you switch to the Export Persona you can see that the "Tower1Projectile" slice actually shows up empty. It also exports an empty PNG. The bounding box for it does not show in the document view, and the dimensions of it (in the "Transform" palette) still show as the dimensions it was BEFORE switching the DPI.

 

I created a new layer, added a 5x5 rectangle to it and created a new slice from that, and that works the way I expect.

Share this post


Link to post
Share on other sites

Yeah, I was expecting to have to re-create the slice, but that's exactly my issue. When I recreate that slice, the measurements are wrong, and the bounding box doesn't show up. :(

Share this post


Link to post
Share on other sites

Slices are always aligned to whole document pixels.  A 2x and 3x should give you documents that are 2 and 3 times the original whole pixel size.

 

When exporting a linked slice, the bounding box for that layer being exported is widened to whole pixels.

 

We do have a bit of code that corrects documents that were created with retina DPI (144, for example).  This might have some affect like you are describing. They are assumed to already be in retina format, and that might be an odd pixel count.  The 1x version will then be 50% of the original size instead (which will be halved then rounded - so a 13 pixel document would come out at 6 pixel, for example).  Use 72dpi, then your document is assumed to be in standard mode, and 2x and 3x export will work as expected.

 

If you have an example, I can look into it.


SerifLabs team - Affinity Developer
  • Software engineer  -  Photographer  -  Guitarist  -  Philosopher
  • iMac 27" Retina 5K (Late 2015), 4.0GHz i7, AMD Radeon R9 M395
  • MacBook (Early 2015), 1.3GHz Core M, Intel HD 5300
  • iPad Pro 10.5", 256GB

Share this post


Link to post
Share on other sites

Is there an easy way to adjust a slice's size numerically? The only way I can see is to zoom way in and scale each side it to a point edge. This is tedious enough that I would probably rather use other software... :(

 

You can adjust the position and size of a slice using the Transform panel.


SerifLabs team - Affinity Developer
  • Software engineer  -  Photographer  -  Guitarist  -  Philosopher
  • iMac 27" Retina 5K (Late 2015), 4.0GHz i7, AMD Radeon R9 M395
  • MacBook (Early 2015), 1.3GHz Core M, Intel HD 5300
  • iPad Pro 10.5", 256GB

Share this post


Link to post
Share on other sites

Whoops, I thought I had attached that document a couple posts ago. 

 

Slices snapping to whole pixels: that's great! But my issue is that I want them to snap to whole points, rather than pixels. My document was set to 1024x768 points, with a dpi of 144 (so that I still had the resolution to export @2x without issue, or that was my intention, in case I used any pixel layers).

 

So I was getting slices that were snapping to odd-numbered pixel dimensions, which exported @2x graphics at that size. Which means the "@1x" graphics could not be exactly half the size of the @2x graphics.

 

In any case, the attachment here demonstrates a problem I found when trying to change my document resolution to 72, to try to force the slices to be calculated with whole pixels at the "@1x" level, rather than at the @2x level. When I did that, I had problems creating layer slices from layers that had already existed in the document, *before* the resolution change. There was no problem making layer-based slices from newly-created layers.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×