本文整理汇总了PHP中imagick::writeImageFile方法的典型用法代码示例。如果您正苦于以下问题:PHP imagick::writeImageFile方法的具体用法?PHP imagick::writeImageFile怎么用?PHP imagick::writeImageFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类imagick
的用法示例。
在下文中一共展示了imagick::writeImageFile方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: imagick
<?php
define("JPEG_FILE", __DIR__ . "/imagick_test.jpg");
define("PNG_FILE", __DIR__ . "/imagick_test.png");
$im = new imagick('magick:rose');
$im->writeImage(JPEG_FILE);
$im->clear();
// This is the problematic case, setImageFormat doesn't really
// affect writeImageFile.
// So in this case we want to write PNG but file should come out
// as JPEG
$fp = fopen(PNG_FILE, "w+");
$im->readImage(JPEG_FILE);
$im->setImageFormat('png');
$im->writeImageFile($fp);
$im->clear();
fclose($fp);
// Output the format
$identify = new Imagick(PNG_FILE);
echo $identify->getImageFormat() . PHP_EOL;
// Lets try again, setting the filename rather than format
// This should cause PNG image to be written
$fp = fopen(PNG_FILE, "w+");
$im->readImage(JPEG_FILE);
$im->setImageFilename('png:');
$im->writeImageFile($fp);
$im->clear();
fclose($fp);
// If all goes according to plan, on second time we should get PNG
$identify = new Imagick(PNG_FILE);
echo $identify->getImageFormat() . PHP_EOL;