3

I have to resize images, cause we upload printable high res images and for the preview people dont need a 4000px+ image. Some images using the rgb color space "eci" and others using the color space srgb. The srgb files dont have any problems, but the eci looking a bit colourless than before. And when I upload a transparent image, its not perfect transparent. Is there any solution? When I resize and its a png image, I use following extra function.

private function imagetranstowhite($trans) {
    // Create a new true color image with the same size
    $w = imagesx($trans);
    $h = imagesy($trans);
    $white = imagecreatetruecolor($w, $h);

    // Fill the new image with white background
    $bg = imagecolorallocate($white, 255, 255, 255);
    imagefill($white, 0, 0, $bg);

    // Copy original transparent image onto the new image
    imagecopy($white, $trans, 0, 0, 0, 0, $w, $h);

    return $white;
}

Does anyone have a solution? Imagemagick instead of gdlib is fine too.

emcconville
  • 23,800
  • 4
  • 50
  • 66
TobiasHH
  • 125
  • 1
  • 10

2 Answers2

0

For people with the same problem in the future. I solved it by stopped using imagegd and switched to ImageMagick. All images are still transparent and u can easily convert cmyk images to sRGB with the correct ICC profile

TobiasHH
  • 125
  • 1
  • 10
-2

Don't make the PNG bigger, virtually. Instead, start out with as big of a PNG's resolution as you'll require and then virtually shrink it as needed. That way you'll keep the resolution on the PNG and never have to mess with it again, after that. It's the quickest, easiest, and best solution possible.

user1789573
  • 515
  • 2
  • 8
  • 23