Wrong exported image size (extra pixel added) if artboard coordinates are non-integer, not pixel-perfect
In attached AI file there are 1 artboard if you just export it for Screens you will get an image size 105px × 104px, however in AI it's sized as 104x104px.
Check that X coordinate of artboard is 172.34 px, so it's float. Just change it to 172px and re-publish and image will be 104x104.
So, coordinates of artboard should affect into output PNG image.
Also, should be related too:
https://illustrator.uservoice.com/forums/601447-illustrator-bugs/suggestions/20530969-export-for-screens-adds-extra-pixels-at-to-exports
AI 21.1.0 macOS
This issue is probably happening because the artboard dimensions are not appropriate for raster export (i.e. are in decimals).
If you make x and y values as the whole numbers in the transform panel (not in decimal), then the extra pixels will not be added to the exported image.
That is the workaround, and it’s reported that it’s not always the case.
At the same time — Ai knows the size of artboards to be exported and yet it does not deliver the set sizes, which is not fair. The team is going to rethink the algorithm.
-
Ben Kraft commented
Sounds good, thanks for the tips. Feel free to merge, I appreciate all the help! 👍
-
Glad it worked for you.
Coloration can be different because of the color management. Perhaps the scripting method doesn't write the current color profile into the image, and you viewer respects profiles. Sadly, I don’t have enough knowledge on how it’s handled... but I suggest visiting Adobe Community, Scripting section), and asks the question there: community.adobe.com/t5/illustrator/ct-p/ct-illustrator&tabid=discussions&topics=label-scripting
Please also share there your actual color settings, along with the test file and test results, so people can try to figure it out. Forums are great.If it turns out to be a bug — come back here and log it.
As for this one — do you mind me merging it into the larger one? -
Ben Kraft commented
@Egor Thanks for the response!
That's an interesting point, my artboard was originally at a global `X:745` `Y:152.5`, and changing to `X:750` `Y:150` seems to have consolidated all of the results! Great catch and agreed; this seems like something that would cause many further issues.
It's interesting and now easier to notice that JavaScript handles anti-aliasing *slightly* differently than traditional exports (some small coloration differences). It's barely an issue but curious if you happen to know the reason?
-
Ben, this is a great observation and a well-writted and documented report.
Thank you for this.What are the coordinates of your artwork? As I see it, Illustrator documents are point grid based internally, and integer global coordinates for both artboards and objects are critical to have crisp results without fractions of a point/pixel creeping into the rasterization. Obviously Ai should use local grid... there is a larger general report on that topic, http://illustrator.uservoice.com/forums/601447/suggestions/30992416
If you have this problem, but the coordinates (both for artboard and global rulers) are integers — please share the test file, so the team can review it.
If fixing coordinates solves the problem — again, please comment back. -
Ben Kraft commented
“Export As” yields very different .png results than “Asset Export”, “Export for Screens”, and JavaScript `doc.exportFile()`, especially when attempting to export an artboard.
This often is seen as assets being clipped from the edges of artboards resulting in soft edges or “transparency bleeding”, or exporting as different dimensions than the selected artboard.
The test I ran attempted to export an asset of dimensions 50x250 points fully left-center aligned to an artboard of dimensions 350x250, with an export scaling of 1x. When presented with the option, anti-aliasing was always toggled, and in JavaScript, the settings were:
```
var options = new ExportOptionsPNG24();
options.antiAliasing = true;
options.artBoardClipping = true;
```It appears as though Asset Export and Export for Screens yielded the same results (both with incorrect dimensions and "transparency bleeding"), but different than Export As (correct dimensions, no bleeding) which was different from the JavaScript method (correct dimensions, bleeding).
This, for me, means I cannot use JavaScript for my exporting and must manually export my assets one by one, which is very tedious.
-
Angel Neo commented
I've always exported my files in 72ppi for web/online files but recently my files don't save at the exact dimensions? They've been exporting as an addition of 1px. For example my artboard is 810× 1440px but it exports 811 × 1441px?
I'm not sure wether it's a bug or I have the wrong settings and for now I've been making my artboards 1px lesser to save my files:( -
Stephan Mönninghoff commented
Please make sure the "Rearrange Artboards" command does not mess up the position of artbords, with artboards ending up four decimal places off the pixel grid. Rearranging artboards should be safe, particularly, if the "Align Art to Pixel Grid" preference is ON!
-
Ruud van den Berg commented
Thanks, Egor. You solved my issue. I furthermore export using the artboard.
-
Ruud van den Berg commented
Thanks, Egor. Please merge, I do not mind at all.
Have a nice Sunday, Ruud
-
Ruud, instead of using the final sizes of the artboards specified, Illustrator calculates these based on their coordinates on the global document grid.
if you pick the Artboard tool and check the X/Y values in the Control or Properties panel, you'll see that the artboard is not placed exactly one the grid — like the attached coordianates_fractions.png shows.
If you change them to be integer, like the second image shows, this file gets exported as 120005 × 9005.This is a known problem, reported here: http://illustrator.uservoice.com/forums/333657/suggestions/30992416
Would you mind me merging your report with this one? -
Ruud van den Berg commented
This is a sample document. When exported, it even becomes a 120006 x 9006 PNG
-
Strange... Would you mind sharing the copy of the file here, please? Remove everything, but keep the layout of artboards.
I am testing this and can’t reproduce, so perhaps it’s file-specific. Needs a close look. -
Ruud van den Berg commented
The artboard is also (exactly) 2880 x 2160 px and properly aligned
-
Can you check the coordinates of the artboards, please? Are these integer numbers, without any fraction?
-
Ruud van den Berg commented
Most of my work is a 2880 x 2160 px (300 dpi) PDF (AI). When I export at 300 ppi/supersampling as PNG it becomes 12001 x 9001 px in stead of 12000 x 9000 px. The additional pixels are transparent.
-
Do not worry. I just wanted to make sure this is the same popular problem reported earlier — it is.
The main reason this happens — fractional coordinates the artboard has. Once you reset rulers, this should get exported fine (although some report it does not help).This explains it, but doesn’t excuse though... and it should be fixed eventually.
As I said before in the comments to this report, Ai knows the final size a user wants, and it should stick to it. -
K-O commented
sorry, for one by one. site wont allow for upload of a zip.
-
K-O commented
export selection jpg
-
K-O commented
artboard export for screens png
-
K-O commented
artboard export for screens jpg