Recently, when the image format is CMYK, the Image Upload browser cannot display the image normally, and the scaling of the image turns into a black screen,
Later, Google found that ImageMagick has powerful functions. you can install ImageMagick in two ways: 1) directly compile and install it with PHP and call it in the program; 2) directly install it and call system commands.
For simplicity, we have adopted 2nd types and directly used PHP or JSP to call the convert command to convert images from CMYK format to RGB format:
Convert. php
<? PHP
Exec ("/usr/local/bin/convert-colorspace RGB/mnt/SMB/proimg_original/img_u/shop_img/89/cs01831/logs/mnt/SMB/proimg_original/img_u/shop_img /89/cs01831/sregist_1259723804077.jpg ");
?>
PHP convert OK !!
Convert. jsp
<%
Process Objective C ("/usr/local/bin/convert-colorspace RGB/mnt/SMB/proimg_original/img_u/shop_img/89/cs01831/logs/mnt/SMB/proimg_original/img_u /shop_img/89/cs01831/sregist_1259729434254.jpg ");
%>
JSP convert OK!
At the same time, a simple Java function is provided to facilitate integration in Java:
Public static Boolean cmyk2rgb (string file ){
File d = new file (File );
If (D. isdirectory ()){
Try {
String [] commands = {"/bin/sh", "-c", "/usr/local/bin/convert-colorspace RGB" + file + "" + file };
Process = runtime.getruntime(cmd.exe C (commands );
Process. waitfor ();
Return true;
} Catch (exception e ){
E. printstacktrace ();
Return false;
}
}
Return true;
}