Need help to rewrite code

Hi everyone,

I will try to make this short. I need to alter the code function below to use imagicks resize function instead.

[php]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 ) );
    }

[/php]

The code above does the job of creating a different size of my original photo at the time of purchase - but as an photographer it also takes away all information on the photo. This renders a photo useless since all colorprofile, copyright, resolution is gone.

From what I have been told - imagick does this differently and saves the exif information. So I need this function to use imagick:resize instead of imagecopyresampled.

A note: the function must preserve original file.

To explain the workflow. I upload my original image to the site - a newspaper or magazine sees the image and want a medium sized image - they buy that and tells the shopping cart to create a medium sized photo from the original and makes it ready for download.

Can anyone help me? I hope you understand - english is not my spoken langugage.

//mxfarsa

Sponsor our Newsletter | Privacy Policy | Terms of Service