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.
-
Bobby Wasleth Krøyer commented
So when creating a document for example 1920x1200 px you export in "Export for screens" or any other export options. Then the exported image will be 1921x1201 px which is super annoying. This has to be fixed asap!
-
@Matthieu, this is another problem, and it’s simple math, and a bane of the metric world :)
The resolution values you used are not ALL possible ones, you forgot to set a custom one — and to get nice integer linear sizes in centimeters we HAVE to use a a fractional value.
300 ppi (point per inch) means each 25.4 mm (1 inch equals to it today) will have 300 pixels. The other way around means 1 cm will have 118,11 pixels. And pixels can’t be cut in fractions. So these get rounded. That makes your 28 cm with 300 ppi equal 28×118.11 = 3307,08 pixels. If rounded down, your 28×40 cm becomes 279,99×399,97 cm (3307×4724 px), if rounded up (like i happens in your case) — 28,01×40,01 cm...Photoshop offers PPCM as a unit of resolution, one can change in Preferences. Illustrator offers none. Here is the request you can upvote: http://illustrator.uservoice.com/forums/333657/suggestions/32403901
Until then, some of use have to use fractional values for PPI, to get clean linear sizes: 304.8 ppi to get 120 ppcm, 508 ppi to get 200 ppcm, etc.
-
Matthieu commented
I created a 28x40cm file in Illustrator and tested all the different export options (Save, Save As, Export), as well as all possible resolutions (72 and 300 dpi).
No matter what I do, the file is always generated as 28.01 x 40.01cm. I’ve tested this multiple times, even with blank files, and the issue keeps happening.
This isn’t a problem with the artboard positioning—it’s perfectly aligned to 0,0.
This has been a recurring issue all year, and we’re wasting hours fixing visuals when exact dimensions are required.
How is it possible that this bug has been around for more than 8 years and still hasn’t been fixed? Seriously, do I need to switch to Affinity just to get a basic feature like this to work properly? This is beyond frustrating!
-
Anonymous commented
@martin holtorf it's been way longer, like 2-3+ years. Do the right thing, cancel your Adobe Sunscription and switch to Affinity like I did!
-
Martin Holtorf commented
I've just come across this bug and am amazed, that this bug is still "under review" late 2024, almost a year later.
Please get this resolved. If the team "has to rethink the algorithm" - at least add a text to the tooltip when creating a new Artboard, that a non-integer X,Y position may affect the pixel size of the exported artwork, irrespective of the chosen Artboard size.
-
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.