Changes to PictureManager for PNG Transparency

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
13 years ago
The current PictureManager doesn't preserve transparency when resizing transparent PNGs. The following modified PictureManager.cs file fixes it and a few other things:

UPDATED 22-SEPT-2010
http://www.mediafire.com/file/1dudv4pxn8dddiz/PictureManager_PNG_Transparency_Fix.zip (file and instructions)
http://www.mediafire.com/file/94eai7gbigwxrsa/PictureManager.cs (file only)

Changes to PictureManager.cs:
    -changed method name getImageCodeInfo to getImageCodecInfo (fixes typo)
    Updates in GetPictureUrl() method:
        -GIFs use white background (instead of graphic object's default of black)
            -uses image codec "image/jpeg" for GIFs for better quality
            -implements current behavior where all images use the jpeg codec
        -use actual codec info when saving the image (instead of hard-coded "image/jpeg" -used as fallback value and for GIFs)
    Updates in ValidatePicture() method:
        -added extension parameter to use for getting actual codec info when saving the image (instead of hard-coded "image/jpeg" -used as fallback value and for GIFs)
        -This affects methods: InsertPicture() and UpdatePicture() (updated their calls to ValidatePicture())

These changes refer to version 1.80. After apply the changes, you will need to recompile the solution.

.
13 years ago
Thanks a lot
13 years ago
I've just tested this PictureManager with a default nopCommerce installation. And it generates a border on JPEG images. Try to visit $25 Virtual Gift Card page (public store).
13 years ago
The code has been updated (removed pixel format -wasn't needed and caused the border). ImageCodecInfo is enough to preserve transparency for PNGs, the white background is still set for GIFs though as the default is a black background and GIFs are still saved as JPEGs for better quality.

Also removed the change to use jpg as the extension as some carts may already use jpeg as the extension (for files not stored in DB).

.
13 years ago
Thanks again
13 years ago
Hi

Just replace every image/jpeg by image/png in the file PictureManager.cs
In version 1.80 this can be found on lines 154, 376 and 500 in the file.
The file can be found in the folder $(Root)\Libraries\Nop.BusinessLogic\Media

The thumnails will increase in size because of the png format, so traffic wil increase.

Hans
13 years ago
Please see changet 57365
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.