Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

mxfarsa on "Replace GD resize function with Imagemagick."

$
0
0

Hi everyone,

This issue may not be easy to fix, I do not know but here it is.

I am selling photos online to different newspapers, they buy and download one image or more with a size (Large, medium or small) when selected the site resizes the image and make it available for download - so far everything is working perfectly and as it should. But and this is a big but, when it resizes the image all exif and metadata is lost - som instead of a image with correct colorprofile, meta data, and resoultion, the customer gets a image in 96ppi (not 300ppi) that they bought....

The shopping solution I use are doing the resize and using wordpress GD library and when the code "imagecopyresampled" is used that is when metadata and exif gets lost.

So to test out if using imagemagick does a better job of keeping the data i now need to change the code to use imagemagick instead of GD library.

I am not a programmer so here is the original code of the resize function:

public function create_download_size( $size, $location=null ){

        $image_p = imagecreatetruecolor( $size['width'], $size['height'] );
        $image = imagecreatefromjpeg( $location );

        list( $current_image['width'], $current_image['height'] ) = getimagesize( $location );
        imagecopyresampled($image_p, $image, 0, 0, 0, 0, $size['width'], $size['height'], $current_image['width'], $current_image['height']);

        $destination_file = $this->tmp_dir . basename( $location );

        if ( ! file_exists( $destination_file ) ){
            wp_mkdir_p( dirname( $destination_file ) );
        }

[Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum's parser.]

Now one thing the function must leave the original image alone and create a new size temporarily for the download.

How do I switch this function to use imagemagick instead of GD for the same operation?


Viewing all articles
Browse latest Browse all 8245

Trending Articles