• gabrielwolf

    (@gabrielwolf)


    Can you provide me with a patch, so that the original icc profiles are preserved? I tried it myself, but it doesn’t work out.
    iptc is no problem, but icc doesn’t show up.

    // Resize file using PHP Imagick class
    function ime_im_php_resize( $old_file, $new_file, $width, $height, $crop, $resize_mode = 'quality' ) {
    $im = new Imagick( $old_file );
    if ( ! $im->valid() )
    return false;

    try {
    $iptc = $im->getImageProfile('iptc');
    $icc = $im->getImageProfile('icc');
    $quality = ime_get_quality( $resize_mode );
    if ( is_numeric( $quality ) && $quality >= 0 && $quality <= 100 && ime_im_filename_is_jpg( $new_file ) ) {
    $im->setImageCompression( Imagick::COMPRESSION_JPEG );
    $im->setImageCompressionQuality( $quality );
    }
    if ( method_exists( $im, 'setImageOpacity' ) )
    $im->setImageOpacity( 1.0 );

    if ( $resize_mode == 'size' )
    $im->stripImage();

    if ( $crop ) {
    /*
    * Unfortunately we cannot use the PHP module
    * cropThumbnailImage() function as it strips profile data.
    *
    * Crop an area proportional to target $width and $height and
    * fall through to scaleImage() below.
    */

    $geo = $im->getImageGeometry();
    $orig_width = $geo[ 'width' ];
    $orig_height = $geo[ 'height' ];

    if( ( $orig_width / $width ) < ( $orig_height / $height ) ) {
    $crop_width = $orig_width;
    $crop_height = ceil( ( $height * $orig_width ) / $width );
    $off_x = 0;
    $off_y = ceil( ( $orig_height - $crop_height ) / 2 );
    } else {
    $crop_width = ceil( ( $width * $orig_height ) / $height );
    $crop_height = $orig_height;
    $off_x = ceil( ( $orig_width - $crop_width ) / 2 );
    $off_y = 0;
    }
    $im->cropImage( $crop_width, $crop_height, $off_x, $off_y );
    }

    $im->scaleImage( $width, $height, true );

    $im->setImagePage( $width, $height, 0, 0 ); // to make sure canvas is correct
    $im->setImageProfile('iptc', "$iptc");
    $im->setImageProfile('icc', "$icc");
    $im->writeImage( $new_file );

    return file_exists( $new_file );
    } catch ( ImagickException $ie ) {
    return false;
    }
    }

    I also tried to patch the command line way, same result. ICC is striped out….

    Thank you.

    https://www.ads-software.com/plugins/imagemagick-engine/

Viewing 1 replies (of 1 total)
  • Thread Starter gabrielwolf

    (@gabrielwolf)

    I got no answer from the core forums aswell. Is icc profiles not interesting for anybody? All the new browsers support it, but the webdesign comunity is not interestet?

    Anyone here?

Viewing 1 replies (of 1 total)
  • The topic ‘Embedded ICC Profiles are removed, how to preserve them?’ is closed to new replies.