Recently, when the image format is cmyk, the Image Upload browser cannot display the image normally, and the image scaling turns into a black screen. Later, google found that imagemagick is very powerful and can be installed in two ways. 1) directly compile and install with php and call it in the program; 2) directly install 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
Copy to ClipboardReference: [www.bkjia.com] <? 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
Copy to ClipboardReference: [www.bkjia.com] <%
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:
Copy to ClipboardReference: [www.bkjia.com] 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 process = runtime.getruntime(cmd.exe c (commands );
Process. waitFor ();
Return true;
} Catch (Exception e ){
E. printStackTrace ();
Return false;
}
}
Return true;
}
Source: http://www.cnblogs.com/coffee_cn/