TL;DR
Has the default changed for some import option?
From the investigation given below we see three important changes:
By default FrontEnd of version 13.0.0 applies to the whole Notebook window a hidden scale of 96/72 upon rendering on the Windows OS. This unnecessary scaling is the only reason for the observed low image rendering quality in the FrontEnd.
The reason why you didn't notice this when pasting an image
from the clipboard is that in version 13.0.0 the FrontEnd by default sets ImageResolution -> {96., 96.}
for the image
in the clipboard. Then upon conversion into boxes, it sets the ImageSizeRaw
option of obtained GraphicsBox
to the value equal to (72/96)*ImageDimensions[image]
. This often results in non-integer values of ImageSizeRaw
, which in turn leads to rounding them down by the FrontEnd and in turn also low image rendering quality after applying the hidden scale factor 96/72. But when the image
is large this effect is not so apparent as when you Import
the image. You can see these effects yourself:
img = RandomImage[1, {110, 113}, ImageResolution -> 96]
Options[ToBoxes[img], ImageSizeRaw]
- Despite the
ImageSize -> 144
explicitly specified in g1
, export to PDF of version 12.3.1 sets ImageSize -> 104
, while in version 13.0.0 it correctly sets ImageSize -> 144
.
Note that it is possible to disable applying the 96/72 scale in version 13.0.0 using the undocumented FrontEnd option "ScreenResolutionCompatibilityMode"
(you should restart Mathematica after evaluating this):
CurrentValue[$FrontEnd, "ScreenResolutionCompatibilityMode"] = True
But this only works if all of your displays are set to 100% under the "Display" in the Windows "Settings" application. And of course, there is no guarantee that this will continue to work in future Mathematica versions.
Another possible workaround is to apply default Magnification -> 72/96
to all GraphicsBox
objects in the FrontEnd (Image
appears inside of a Notebook as GraphicsBox
, as well as Graphics
):
SetOptions[$FrontEnd, GraphicsBoxOptions -> {BaseStyle -> Magnification -> 72/96}]
After evaluating this the described problem disappears:
The investigation
Starting from version 12.2, the default import element for PDF format is "PageImages"
, which means that the contents of the pages will be rasterized upon import. Let us compare ImageDimensions
of obtained images (on Windows 10 x64):
Export["temp.pdf", g1];
im = First@Import["temp.pdf"]
im // ImageDimensions
With version 12.3.1 (Notebook Magnification is set to 100%):
With version 13.0.0 (Notebook Magnification is set to 100%):
We see that the dimensions of the obtained images are substantially different. Even more interesting, here is what happens when we import in version 12 the PDF exported from version 13, and vice versa:
Let us import them as "PageGraphics"
instead and check the values of the ImageSize
option:
gr12 = First@Import["ver12.3.1.pdf", "PageGraphics"]
gr13 = First@Import["ver13.0.0.pdf", "PageGraphics"]
Options[#, ImageSize] & /@ {gr12, gr13}
Indeed, ImageSize
s are different and equal to ImageDimensions
obtained with version 12.3.1.
So, from where come ImageDimensions
obtained with version 13?
By default under Windows Mathematica 13 uses hidden global magnification equal to 96/72:
SystemInformation["Devices", "ConnectedDisplays"]
Multiplying 104 and 144 by 1.33333333 and rounding produces 139 and 192, correspondingly.
The actual reason for the low quality of displayed images in version 13 is that they are magnified by the factor of 96/72 by default. Let us try to overcome this by magnifying them by the factor of 72/96 in version 13.0.0:
Image[Import@"ver12.3.1.pdf", Magnification -> 72/96]
Image[Import@"ver13.0.0.pdf", Magnification -> 72/96]
We see that the quality is actually quite good.