Copy link to clipboard
Copied
I have a png image (many of them actually) that were given to me in the right pixel size but set at 72dpi. They need to be 96dpi as they are for use in a program and WPF seems to care and tries to scale them if they are not 96 to start. I figured that's an easy fix, created a quick action to change to 96 and ran in batch on the folder. Everything ran fine, but when I open them they are all 96.012dpi. I tried doing it manually on one of them and I can set it to 96 exactly, and when I go back into it, it's still set to exact 96. However when I save, close, and reopen the file it's back to 96.012. I know it doesn't seem like it would make much difference but if it's not exactly 96 WPF will try to scale it and it ends up with some blurring on the edges, etc.
What can I do to set the images as 96 exactly and why won't it stick?
Copy link to clipboard
Copied
Did you resize them with resample turned on or off? It's best to change the resolution and not resize the image. You do this by unchecking the resample box.
The images are changing to 96.012 because the print size is not equally divisible by 96 pixels.
Copy link to clipboard
Copied
Hi
... they are for use in a program and WPF seems to care and tries to scale them...
When you say WPF, what do you mean exactly ?
Pierre
Copy link to clipboard
Copied
postrophe wrote:
When you say WPF, what do you mean exactly ?
Pierre
I thought it was a typo, but P is not near enough to T on the keyboard for that to work.
Theresa is on the right track I reckon. Resize was given some impossible math to contend with, and had to compromise. Those pesky pixels can really get in the way sometimes.
Copy link to clipboard
Copied
Sorry, WPF = Windows Presentation Foundation. It's for a program I'm writing so I'm used to posting in coding forums more than Photoshop, I should have expanded that. It's just a graphic rendering system that .NET uses for programs, but if the image isn't 96 dpi it tries to scale it and ends up with blurry edges. Trevor.Dennis haha, sometimes it leaves you saying WTF, but no it was actually supposed to be WPF .
I will try playing with the pixel size of the image and see if I can get it to stick to 96, thanks for the advice.
Copy link to clipboard
Copied
And yes I resized with resample unchecked. Actually tried both ways with the same result...
Copy link to clipboard
Copied
I don't think that's it. I changed the canvas size to 96x48 pixels which is easily divisible by 96 (1 inch by 1/2"). I then went back to image size and set it to 96dpi exactly and after save and reopen it still goes back to 96.012...
Here is one of the images if it helps anyone (not sure if that's the best way to attach it here...).
Copy link to clipboard
Copied
That is really odd. Where are you reading 96.012 ppi? This is what I see in the PS image size dialog.
Copy link to clipboard
Copied
I'm on CS5, but here is the image size dialog for the original pixel size:
and here is after I change the pixel size to make it divisible:
Copy link to clipboard
Copied
That is odd. I don't have an answer for you, but I'm not sure if the fraction of a pixel really matters anyway.
Copy link to clipboard
Copied
Normally I'd say you are right and the fraction of a pixel isn't a big deal, but it's causing the display system to try and resize and ending up making the image look less crisp.
Copy link to clipboard
Copied
what happens if you create a blank new document at the necessary pixel dimensions and resolution, then place the asset to fit, and export to a new file?
Copy link to clipboard
Copied
Good idea, let me try that...
Copy link to clipboard
Copied
Nope, still comes out 96.012
Copy link to clipboard
Copied
Hi
Hum .. are both images ( input / output ) use the same Mode ?
Seem maybe one is "Indexed Color" converted to "RGB" ??
Pierre
Copy link to clipboard
Copied
I will check, but not sure why the mode would make a difference on resolution...
Also units are inches and have been the whole time.
Copy link to clipboard
Copied
Dimension in inches, pixel numbers and resolution are not independent.
Of course 96 pixels and one inch should result in 96 ppi.
With these settings (with resampling) I get exactly the intended result.
The image shows the settings before the conversion. The state after the
conversion is exactly the same.
In #8 Resample is not checked.
Best regards --Gernot Hoffmann
Copy link to clipboard
Copied
‌What are your units in Photoshop (can see inches in dialog but did you change it?)
Copy link to clipboard
Copied
‌Suggestion, programmer level. Get hold of pngcheck, compare pHYs chunks. 96.012 seems to me the closest possible value because resolution if present is in pixels per metre and is an integer.
Copy link to clipboard
Copied
Thanks for the tip on pngcheck, I will see what I can find there...
Copy link to clipboard
Copied
I've been hesitant to post in this thread, because I know absolutely nothing about programming or the Windows Presentation Foundation.
But if this is for screen viewing, the ppi shouldn't matter - ppi is metadata used by printer drivers to calculate print size.
For screen viewing, pixel dimensions are all that matter, so what happens if you use slightly different pixel dimensions?
Copy link to clipboard
Copied
Thanks for the input. Unfortunately it does matter as WPF does not render pixel for pixel always. It tries to the image properly size, device independent; so if you have an image that is set to a certain size at 72dpi and your screen resolution is 96dpi it will try to scale it up to make it the same actual size at the new resolution, which is why it's trying to scale my image...
Copy link to clipboard
Copied
Try Save For Web with metadata "none".
This strips all resolution/size metadata from the file so that it actually doesn't have a ppi. Don't get confused by the fact that Photoshop reopens it as 72ppi - this is just a default value that PS assigns because it has to assign something.
Copy link to clipboard
Copied
D Fosse,
I did not know that resolution/size was contained in the metadata but it makes perfect sense. Thanks for sharing. You just gave me an 'ah ha' moment.
Copy link to clipboard
Copied
In which context is this deviation of 0.012/96 = (about) 10 to the power of minus 4
anywhere of any relevance for building a page?
Best regards --Gernot Hoffmann