मंच में http://www.php.net/gd पर निम्न टिप्पणी लिखा है:
आईई TIFF फ़ाइलों और मानक PHP वितरण प्रदर्शित नहीं करता है करने के लिए/परिवर्तित TIFF से समर्थन नहीं करता।
ImageMagick (http://www.imagemagick.org/script/index.php) एक निःशुल्क सॉफ़्टवेयर है जो विभिन्न प्रकार के प्रारूपों में छवियों को पढ़, परिवर्तित और लिख सकता है। विंडोज उपयोगकर्ताओं के लिए इसमें एक PHP एक्सटेंशन php_magickwand_st.dll शामिल है (और हाँ, यह PHP 5.0.4 के तहत चलता है)।
टीआईएफएफ से जेपीईजी में कनवर्ट करते समय, आपको सीएमवाईके कलर स्पेस से आरजीबी कलर स्पेस में भी कनवर्ट करना होगा क्योंकि आईई सीएमवाईके जेपीजी को भी नहीं दिखा सकता है। कृपया ध्यान दें: -TIFF फ़ाइलों आरजीबी या CMYK रंग अंतरिक्ष -JPEG फ़ाइलों आरजीबी या CMYK रंग अंतरिक्ष हो सकता है
यहाँ ImageMagick एक्सटेंशन का उपयोग कर उदाहरण कार्य हैं हो सकता है: - JPEG फ़ाइल स्वरूपों के लिए TIFF परिवर्तित - करने के लिए CMIK कन्वर्ट आरजीबी रंग अंतरिक्ष - 300 DPIs को सेट छवि संकल्प (पिक्सेल में छवि का आकार परिवर्तन नहीं करता है)
<?php
function cmyk2rgb($file) {
$mgck_wnd = NewMagickWand();
MagickReadImage($mgck_wnd, $file);
$img_colspc = MagickGetImageColorspace($mgck_wnd);
if ($img_colspc == MW_CMYKColorspace) {
echo "$file was in CMYK format<br />";
MagickSetImageColorspace($mgck_wnd, MW_RGBColorspace);
}
MagickWriteImage($mgck_wnd, str_replace('.', '-rgb.', $file));
}
function tiff2jpg($file) {
$mgck_wnd = NewMagickWand();
MagickReadImage($mgck_wnd, $file);
$img_colspc = MagickGetImageColorspace($mgck_wnd);
if ($img_colspc == MW_CMYKColorspace) {
echo "$file was in CMYK format<br />";
MagickSetImageColorspace($mgck_wnd, MW_RGBColorspace);
}
MagickSetImageFormat($mgck_wnd, 'JPG');
MagickWriteImage($mgck_wnd, str_replace('.tif', '.jpg', $file));
}
function to300dpi($file) {
$mgck_wnd = NewMagickWand();
MagickReadImage($mgck_wnd, $file);
$img_units = MagickGetImageUnits($mgck_wnd);
switch ($img_units) {
case MW_UndefinedResolution: $units= 'undefined'; break;
case MW_PixelsPerInchResolution: $units= 'PPI'; break;
case MW_PixelsPerCentimeterResolution: $units= 'PPcm'; break;
}
list($x_res, $y_res) = MagickGetImageResolution($mgck_wnd);
echo "$file<br /> x_res=$x_res $units - y_res=$y_res $units<br />";
if($x_res == 300 && $y_res == 300 && $img_units == MW_PixelsPerInchResolution) {return; }
MagickSetImageResolution($mgck_wnd, 300 , 300);
MagickSetImageUnits($mgck_wnd, MW_PixelsPerInchResolution);
MagickWriteImage($mgck_wnd, str_replace('.', '-300.', $file));
}
$file='photos/test-cmyk.tif';
//this is a TIFF file in CMYK format with a 96 DPI resolution
cmyk2rgb($file);
$file = str_replace('.', '-rgb.', $file);
to300dpi($file);
$file = str_replace('.', '-300.', $file);
tiff2jpg($file);
$file = str_replace('.tif', '.jpg', $file);
to300dpi($file);
/* no file name changes as ImageMagick reports 300 DPIs
$file = str_replace('.', '-300.', $file);
*/
list($width, $height, $type, $attr) = getimagesize($file);
$width = $width/3;
$height = $height/3;
echo "<img src=\"http://localhost/$file\" width=\"$width\" height=\"$height\" alt=\"getimagesize() example\" />";
echo "<br />$file => width=$width - height=$height - type=$type - attr=$attr<br /><br />";
$file='photos/test-rgb.tif';
//this is a TIFF file in RGB format with a 96 DPI resolution
cmyk2rgb($file);
$file = str_replace('.', '-rgb.', $file);
to300dpi($file);
$file = str_replace('.', '-300.', $file);
tiff2jpg($file);
$file = str_replace('.tif', '.jpg', $file);
to300dpi($file);
/* no file name changes as ImageMagick reports 300 DPIs
$file = str_replace('.', '-300.', $file);
*/
list($width, $height, $type, $attr) = getimagesize($file);
$width = $width/3;
$height = $height/3;
echo "<img src=\"http://localhost/$file\" width=\"$width\" height=\"$height\" alt=\"getimagesize() example\" />";
echo "<br />$file => width=$width - height=$height - type=$type - attr=$attr<br /><br />";
?>
नोट - हालांकि ImageMagick सही ढंग से 300 DPIs को जेपीईजी फ़ाइलें संकल्प सेट, कुछ प्रोग्राम यह नोटिस नहीं हो सकता है।
वरना
"Imagick" PECL विस्तार
http://pecl.php.net/package/imagick
http://php.net/manual/en/book.imagick.php
का उपयोग स्रोतों और स्थलों (फ़ाइलें? यूआरएल? Http प्रतिक्रिया?) आप क्या करेंगे पर निर्भर करता है कुछ ऐसा:
$image = new Imagick('something.tiff');
$image->setImageFormat('png');
echo $image;
या
$image->writeImage('something.png');
छवि मैजिक –
पर एक नज़र डालें, आपको वेब डिस्प्ले के लिए टीआईएफएफ फाइलों का उपयोग नहीं करना चाहिए, उनके पास कोई भी प्रकार का संपीड़न नहीं है जिससे आपके उपयोगकर्ताओं को अतिरिक्त बाइट डाउनलोड करना पड़ता है (और स्पष्ट रूप से आपको समस्याएं उत्पन्न होती हैं) कुछ क्लाइंट ब्राउज़रों के साथ)। –
@ माइकबंट किसने कहा कि वे उन्हें वेब संदर्भ में उपयोग कर रहे हैं? सिर्फ इसलिए कि एक http सर्वर का उपयोग किया जा रहा है इसका मतलब यह नहीं है कि वे एक वेबसाइट पर हैं। क्या होगा यदि वे उन विक्रेताओं के साथ काम कर रहे हैं जिन्हें टीआईएफएफ फाइलों की आवश्यकता है और वे सिर्फ http पर उन्हें स्थानांतरित कर रहे हैं? –