Message Boards Message Boards

GROUPS:

How to Export image at 2x resolution?

Posted 2 months ago
799 Views
|
4 Replies
|
11 Total Likes
|

Can someone suggest how to export a GIF at 2x resolution?

Export quality is perfect, but doesn't allow specifying RasterSize. Meanwhile using Rasterize reduces antialiasing quality. I suspect it's an issue of figuring what the default gif export function does and reproducing it

System`Convert`CommonGraphicsDump`ExportElementsToRasterFormat["GIF", ##1]

4 Replies

Did you try

Export["test.gif",ImageResize[i,Scaled[2]]]

sometimes I also do

Export["test.gif",Sharpen@ImageResize[i,Scaled[2]]]

Also there is a Neural Network approach:

It's an issue with Rasterization/Opacity which Domen noticed on SE. If I remove all semi-transparent elements, then Rasterize works as expected, with high quality antialiasing.

You can see the difference in the last 2 animations in the embedded notebook.

I just need a workaround that lets me export at 2x the resolution, while preserving high quality antialiasing seen with default Export. Specifying ImageResolution as option to Export has same effect as Rasterize, antialiasing seemingly disappears

enter image description here enter image description here

The default Export is creating an intermediate Image object with a higher ImageResolution. If you watch the link traffic in LinkSnooper, you can see the ExportPacket request go to the FE and the Image[] being returned. On my system, that Image[] is ImageResolution->144, but yours might be different because it's going to use whatever the native image resolution for that window is (I'm running on a Windows system with 150% scaling).

I'm not 100% for certain what the Export code does after that, but if you take your code, tweak the Rasterize to sample at 144dpi, and then do a straight 50% reduction using ImageResize, it comes out looking very much like what Export generates.

ImageResize[
 Rasterize[img, ImageSize -> is, ImageResolution -> 144], is]

But...no need to do the ImageResize yourself. If you simply send the image to Export and add an ImageSize option for Export, it works pretty well.

Aha, thanks, looks like I just needed plain old ImageResize.

So the workflow for exporting 2x graphics is to Rasterize at 4x pixels, Export or ImageResize to 2x pixels, then embed image in the page with 50% size.

I got sidetracked because if we remove transparent elements in Graphic3D, then Rasterize at 2x already gives subpixel rendering, so I thought I had to manually apply an antialiasing setting somewhere

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract