note 108695 added to imagick.getformat

From: Date: Thu, 17 May 2012 23:02:14 +0000
Subject: note 108695 added to imagick.getformat
Groups: php.notes 
Request: Send a blank email to php-notes+get-188052@lists.php.net to get a copy of this message
The getFormat function merely returns the value of the image format, which is not automatically loaded when you read an image. The value you're getting back, then, is merely the value that you set the format to using the setFormat function. That function takes pretty much any string that matches a popular or well-known image filename. It accepts "jpeg" and "gif", but errors out on anything that is not an image filename, like "xyz123" or "zip". How do you know what filetypes you can enter? Use the PHP ImageMagick function 'queryFormats'. If you want to know what type of file you have, you should try using the PHP page for the function 'filetype'. Or, on the other hand, you can use the ImageMagick function getImageFormat (as opposed to the ImageMagick function getFormat). The difference is that getImageFormat actually returns the format of the inputted image. And now, a simple demonstration of the set/get activity in the Format : <?php // Author: holdoffhunger@gmail.com // Imagick Type // --------------------------------------------- $imagick_type = new Imagick(); // Open File // --------------------------------------------- $file_to_grab = "image_workshop_directory/test.bmp"; $file_handle_for_viewing_image_file = fopen($file_to_grab, 'a+'); // Grab File // --------------------------------------------- $imagick_type->readImageFile($file_handle_for_viewing_image_file); // Set/Get Format // --------------------------------------------- $imagick_type->setFormat("bmp"); $imagick_type_format = $imagick_type->getFormat(); // Print Results // --------------------------------------------- print("<pre>"); print($imagick_type_format); print("</pre>"); ?> ---- Server IP: 69.147.83.197 Probable Submitter: 68.9.137.178 ---- Manual Page -- http://www.php.net/manual/en/imagick.getformat.php Edit -- https://master.php.net/note/edit/108695 Del: integrated -- https://master.php.net/note/delete/108695/integrated Del: useless -- https://master.php.net/note/delete/108695/useless Del: bad code -- https://master.php.net/note/delete/108695/bad+code Del: spam -- https://master.php.net/note/delete/108695/spam Del: non-english -- https://master.php.net/note/delete/108695/non-english Del: in docs -- https://master.php.net/note/delete/108695/in+docs Del: other reasons-- https://master.php.net/note/delete/108695 Reject -- https://master.php.net/note/reject/108695 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#188052) next »