Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
$img = new Imagick($filePath);
$cs = $img->getImageColorspace();
// don't use this (it inverts the image)
// $img->setImageColorspace (imagick::COLORSPACE_RGB);
if ($cs == Imagick::COLORSPACE_SRGB || $cs == Imagick::COLORSPACE_RGB){
$profiles = $img->getImageProfiles('*', false);
// we're only interested if ICC profile(s) exist
$has_icc_profile = (array_search('icc', $profiles) !== false);
// if it doesnt have a CMYK ICC profile, we add one
if ($has_icc_profile === false) {
$icc_rgb = file_get_contents('adminusers/script/AdobeICCProfiles/RGB Profiles/AppleRGB.icc');
$img->profileImage('icc', $icc_rgb);
unset($icc_rgb);
}
// then we add an RGB profile
$icc_cmyk = file_get_contents('adminusers/script/AdobeICCProfiles/CMYK Profiles/UncoatedFOGRA29.icc');
$img->profileImage('icc', $icc_cmyk);
unset($icc_cmyk);
}
$img->stripImage();
$pos_punto = strripos($file_letto,"."); //ultima posizione del punto
$nomefile = substr($file_letto,0,$pos_punto); //nome file senza riferimento al tipo
echo "nomefile: ".$nomefile."<br>";
// write it to a temp file
$filePath = $percorso."/".$dir_letta."/".$nomefile."-pdf.jpg";
$img->writeImage($filePath);
Oddly, if I remove all profiles via -strip or +profile, and apply an sRGB profile and then convert to CMYK profile, the result is still inverted. So that tells me that the Profile-APP12 is important in your input and that you do not have a simple sRGB input image.