I have a weird image in my notebook. If I do ImageResize to it. The pixel values of this image is changed.

enter image description here

Sorry, I can not share this image directly. As you can see, exporting it and then importing it back will not reproduce this behavior. So I have to share this notebook here.

What is wrong with this image? How to correctly ImageResize this image without changing its pixel value (Of course, I can not stand exporting and importing)?

  • $\begingroup$ I don't see why you need to share the notebook file instead of adding code as text as is customary, and a link to the original image. I may be overly paranoid, but I still do not like opening potentially executable files from the internet. $\endgroup$
    – MarcoB
    Jul 25, 2023 at 14:58
  • $\begingroup$ @MarcoB Thank you for your comment. I already said in the post if I share exported image, and then you import it. You will not reproduce the weird behavior. $\endgroup$
    – matheorem
    Jul 25, 2023 at 15:03
  • $\begingroup$ @MarcoB By the way, will a Mathematica notebook run anything automatically when it is just opened without evaluating? $\endgroup$
    – matheorem
    Jul 25, 2023 at 15:07
  • $\begingroup$ Potentially, if it contains dynamic evaluations. $\endgroup$
    – MarcoB
    Jul 25, 2023 at 15:09

1 Answer 1


Compare Information[img] and Information[Import["D:\\1.png"]]. You will see that the data type of original image is Real32, while exporting/importing to .png make it Bit16.

You can either change the data type of your image:

ImageResize[Image[img, "Bit16"], 100] // MinMax
(* {0., 1.} *)

or use different resampling method for resizing (see documentation for ImageResize):

ImageResize[img, 100, Resampling -> "Nearest"] // MinMax
(* {0., 1.} *)

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.