Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 63 lines (53 sloc) 1.566 kb
5c0c3e1 @mkoppanen Added test for PHP bug 64208
authored
1 --TEST--
2 Test format support in writeImageFile
3 --SKIPIF--
4 <?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
5 --FILE--
6 <?php
7
70294c4 @mkoppanen PHP 5.2
authored
8 define ("JPEG_FILE", dirname (__FILE__) . "/imagick_test.jpg");
9 define ("PNG_FILE",dirname (__FILE__) . "/imagick_test.png");
5c0c3e1 @mkoppanen Added test for PHP bug 64208
authored
10
11 $im = new imagick ('magick:rose');
12 $im->writeImage (JPEG_FILE);
13 $im->clear ();
14
15 // This is the problematic case, setImageFormat doesn't really
16 // affect writeImageFile.
17 // So in this case we want to write PNG but file should come out
18 // as JPEG
19 $fp = fopen (PNG_FILE, "w+");
20 $im->readImage (JPEG_FILE);
21 $im->setImageFormat ('png');
22 $im->writeImageFile ($fp);
23 $im->clear ();
24 fclose ($fp);
25
26 // Output the format
27 $identify = new Imagick (PNG_FILE);
28 echo $identify->getImageFormat () . PHP_EOL;
29
30 // Lets try again, setting the filename rather than format
31 // This should cause PNG image to be written
32 $fp = fopen (PNG_FILE, "w+");
33 $im->readImage (JPEG_FILE);
34 $im->setImageFilename ('png:');
35 $im->writeImageFile ($fp);
36 $im->clear ();
37 fclose ($fp);
38
39 // If all goes according to plan, on second time we should get PNG
40 $identify = new Imagick (PNG_FILE);
41 echo $identify->getImageFormat () . PHP_EOL;
42
64184f4 @mkoppanen Add optional format parameter for writeImageFile
authored
43 // Lastly, test the newly added format parameter
44 $fp = fopen (PNG_FILE, "w+");
45 $im->readImage (JPEG_FILE);
46 $im->writeImageFile ($fp, 'png');
47 $im->clear ();
48 fclose ($fp);
49
50 // If all goes according to plan, on second time we should get PNG
51 $identify = new Imagick (PNG_FILE);
52 echo $identify->getImageFormat () . PHP_EOL;
53
3c7c333 @mkoppanen Unlink test artifacts
authored
54 unlink (PNG_FILE);
55 unlink (JPEG_FILE);
56
5c0c3e1 @mkoppanen Added test for PHP bug 64208
authored
57 echo 'done' . PHP_EOL;
58 ?>
59 --EXPECT--
60 JPEG
61 PNG
64184f4 @mkoppanen Add optional format parameter for writeImageFile
authored
62 PNG
5c0c3e1 @mkoppanen Added test for PHP bug 64208
authored
63 done
Something went wrong with that request. Please try again.