0
$\begingroup$

I am having trouble preserving image resolutions in Mathematica 13.0.1.

The following is a free high-resolution GIF from Giphy dot com, pasted below for your convenience:

enter image description here

I notice that even if I simply import the image and run ListAnimation on it, the result is a low-resolution image that looks quite un-smooth:

"high-res-gif.gif" // (Import /* ListAnimate)

I have tried setting ImageResolution to 127--I have a 17-inch laptop with a resolution of 1920 by 1080--but the result is still a much grainier image than the original.

EDIT

This link shows what the imported image in Mathematica looks like. I cannot post the image here because it exceeds the 2 MB limit.

It is very easy to see that the imported version of the image is of a much lower quality.

I have tried Chris Degnen's suggestion in the answer below. The following is a snapshot of the image quality:

enter image description here

It is quite easy to see the degradation in image quality.

END EDIT

Is there a specific trick to importing high resolution images?

Thanks in advance.

$\endgroup$

2 Answers 2

2
$\begingroup$

It's not a loss of resolution, they are being stretch filled. That means new pixels need to be synthesized to fill in the missing ones. You can control that method using a (currently undocumented in 13.0) option to RasterBox.

Style[ListAnimate[Import["https://i.stack.imgur.com/DNjgV.gif"], BaseStyle -> {"RasterBoxOptions" -> {"SmoothingQuality" -> "High"}}]]

$\endgroup$
1
  • 1
    $\begingroup$ Perfect! This is exactly what I was looking for. I wish Wolfram Research's documentation made these points clearer. $\endgroup$ May 16, 2022 at 21:15
1
$\begingroup$

The Giphy page says the image is 500 x 500

enter image description here

And the image you're displaying is the same.

frame1 = Import["https://i.stack.imgur.com/DNjgV.gif"][[1]];
ImageDimensions[frame1]

{500, 500}

$\endgroup$
4
  • $\begingroup$ I am not sure you read the question closely before posting the response. The image displayed in the original post is exactly the image from Giphy. My point is that when that same image is imported into Mathematica, the quality is lost. I have edited the post to include a link to the imported image. (I cannot post the imported image since it is bigger than 2 MB in size.) $\endgroup$ May 16, 2022 at 14:21
  • $\begingroup$ ListAnimate[Import["https://i.stack.imgur.com/DNjgV.gif"]] looks fine on Mathematica 13.0.0. Try ListAnimate[Import["https://i.stack.imgur.com/DNjgV.gif"], ImageSize -> 500] $\endgroup$ May 16, 2022 at 15:16
  • $\begingroup$ Thanks for the suggestion about ImageSize. I tried your exact command as above. Please see the edited question for the image quality that I observe. $\endgroup$ May 16, 2022 at 17:08
  • 3
    $\begingroup$ ImageSize->{500, 500} is rarely equivalent to ImageDimensions[frame1]. They use two different units. $\endgroup$
    – ihojnicki
    May 16, 2022 at 18:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.