I have encountered a weird issue, which is that sometimes when I upload .PNG images to my SharePoint Image Libraries, sometimes they get converted to .JPG, BUT when I open the image from the library it gets converted back to .PNG.

I make sure that all the images are indeed .PNG on my local drive just in case, and they are.

What might cause this conversion to happen?

-

Are you talking about the automatic resizes created when you upload an image to a picture library. Typically it will create an 160px max and 640px max and put them in the _t and _w folders of the library respectively. When this is done the resizes are always jpgs. When browsing from a picture library if you click on the thumbnail, then the resize, then it will show your original png. Maybe that is what is happening to you and why you think it's changing from jpg to png?

-
The thing is that it doesn't happen for all the images. Only the a few of them. Is it something sharepoint does in cases when the images are larger than a specific size? –  Daniel Ziga May 10 '12 at 12:20

SharePoint automatically creates two JPG images every time you upload image to a Picture Library: they are thumbnail image and web preview image. They're stored along with the original image in the Picture library.

No in-place conversion happens: the image is converted only once during the initial upload process.

SharePoint needs these extra images to display picture library thumbnail views and item forms correctly, quickly and not causing excessive server load.

You can retrieve your original image at any time, it has permanent server path and could be accessed directly for whatever you need.

Preview images size could be customized through Object Model (customization will affect only new images), you can set up ThumbnailSize, WebImageHeight and WebImageWidth properties of your document library for this purpose. Alternatively to programmatic approach, obviously you can use PowerShell. Here is a simple example:

$web = Get-SPWeb http://localhost # Please, correct the "My pictures" string to correspond your existing library title$library = $web.Lists["My pictures"] # this will set thumbnail maximum size (height or width, whatever is greater) to 90 pixels$library.ThumbnailSize = 90;

\$library.Update()


Unfortunately, at the time of writing there is no way to influence upon the preview pictures quality. However, if you don't like this functionality, you can completely disable this feature, by setting ThumbnailsEnabled property to false.

-
The thing is that it doesn't happen for all the images. Only the a few of them. Is it something sharepoint does in cases when the images are larger than a specific size? –  Daniel Ziga May 10 '12 at 12:20
In my environment, this happens for all images, regardless of their size (I've just tested). –  Andrey Markeev May 10 '12 at 12:36