atl_andy Posted December 26, 2009 Share Posted December 26, 2009 I'm trying to figure out how Imagick works and, after searching Google, the only information I can find is a couple of tutorials. They don't get into the meat of the subject. I have been successful in reading a directory and writing a picture to a new directory. The issue I'm having is using the new picture after it is written to a directory. My simple example will create a thumbnail of a picture and display it on the screen. $dh = opendir('/var/www/images/'); while ($file = readdir($dh)) { if ($file != "." and $file != ".." and is_file($file)) { $img = new Imagick(); $img->readImage($file); if ($img) { $img->thumbnailImage(150,150, false); $img->writeImage('/var/www/images/thumbs/tn.jpg'); header("Content-type: image/jpg"); echo $img; } $img->destroy(); } } closedir($dh); But when I try to use the image, nothing displays: <img src="/var/www/images/tn.jpg" /> I'm not sure if it's a permissions issue, the new file is owned by the web server: -rw-r--r-- 1 www-data www-data 30895 2009-12-26 10:18 tn.jpg The file opens fine in GIMP. Any suggestions? My goal is to create an admin feature on a site so that images are uploaded and resized to thumbnails and displayed in a gallery. I would like to avoid using a 3rd party script so I can learn something new other than tweaking someone else's script. Link to comment https://forums.phpfreaks.com/topic/186381-imagick/ Share on other sites More sharing options...
teamatomic Posted December 26, 2009 Share Posted December 26, 2009 Use a URL. HTH Teamatomic Link to comment https://forums.phpfreaks.com/topic/186381-imagick/#findComment-984262 Share on other sites More sharing options...
monkeytooth Posted December 26, 2009 Share Posted December 26, 2009 your destroying the image via the loop, not storing it Link to comment https://forums.phpfreaks.com/topic/186381-imagick/#findComment-984263 Share on other sites More sharing options...
monkeytooth Posted December 26, 2009 Share Posted December 26, 2009 your destroying the image via the loop, not storing it Never mind, im just tired i didnt read that proper.. maybe i need to wake up a bit more first before i go responding to people. Link to comment https://forums.phpfreaks.com/topic/186381-imagick/#findComment-984264 Share on other sites More sharing options...
atl_andy Posted December 26, 2009 Author Share Posted December 26, 2009 thanks teamatomic, that worked <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <link type="text/css" href="test.css" rel="stylesheet" /> </head> <body> <div id="img"> <img src="http://localhost/images/thumbs/tn.jpg" /> </div> </body> </html> Link to comment https://forums.phpfreaks.com/topic/186381-imagick/#findComment-984269 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.