sweetname Posted October 1, 2008 Share Posted October 1, 2008 Hi. I am trying to get a gd script I wrote to work with ming to make a dynamically sized slide show. I am using the gd script as a CLI script and the ming script is being accessed by the browser. If I save the resized image to a file and load it into my script with fopen, the script runs without any errors. However when I use passthru (I think passthru is the correct function to use? Php.net says that if you are dealing with something like image streams you should use this.) ming gives an error: Fatal error: SWFBitmap::__construct() [<a href='function.SWFBitmap---construct'>function.SWFBitmap---construct</a>]: Unrecognised file type in ... ... on line 147 . I copy and pasted that error. I just cut out the file path because it was really long and didnt fit on my screen very well. I am using imagejpeg($tn,NULL,100); to export my image. In my ming file I am using the following command to call my script: $image = new SWFBitmap(passthru("'$resizeScript' '$filename' '$maxWidth' '$maxHeight' '$imageQuality'")); where $resizeScript = /path/to/gd/script $filename = /path/to/image/for/script $maxWidth = max width for the resized image $maxHeight = max height for the resized image $imageQuality = the jpeg quality number I am not quite sure why this throws an error, because if I am reading the documentation correctly, it should be the same thing as if I saved the resized image to /path/to/resizedImg.jpg and then opened it with fopen("/path/to/resizedImg.jpg ",'rb') , which works with ming and makes my slideshow Is passthru the correct function to be using here? If you need to see more code I can put it up. I forgot to mention: I am running PHP Version 5.2.0-8+etch10 on debian etch and ming version 0.3.0 Link to comment https://forums.phpfreaks.com/topic/126686-question-about-passthru-and-fopen/ Share on other sites More sharing options...
hawkenterprises Posted October 1, 2008 Share Posted October 1, 2008 Um I think you need to re-read the passthru documentation. It talks that passthru is like exec() and executes a command. What you want is a datastream, not an execution. Fopen and filestreams are the right way to go here. Link to comment https://forums.phpfreaks.com/topic/126686-question-about-passthru-and-fopen/#findComment-655217 Share on other sites More sharing options...
sweetname Posted October 2, 2008 Author Share Posted October 2, 2008 are you sure? When I use fopen on my script it just gives me a copy of php code, but when I use passthru on it, it gives me the same binary output as when I use fopen and fpassthru on the saved image that i generated with my script, except instead of outputting it directly, I saved it to a file. I am not very experienced in using filters (I am kinda self teaching myself how to get around with php) so I am not quite sure how I would be able to create a pointer with fopen that would give the binary of an image generated with my script. Would you mind pointing me in the right direction or giving me a small example please? Thanks Edit: I have written my image resizing script to be run from the command line if that makes any difference to you Link to comment https://forums.phpfreaks.com/topic/126686-question-about-passthru-and-fopen/#findComment-655234 Share on other sites More sharing options...
sweetname Posted October 2, 2008 Author Share Posted October 2, 2008 I also tried using popen with my script, and it gives me an error: Jpeg marker not found where expected. That is closer than the unregonized file format error though I think. I am trying to play around with Fopen and the streams but everything I do is just giving me the source code from my script, not the binary like if I use Fopen on an image. Popen is giving me the binary on my script, but it is saying the Jpeg marker is not found where expected in ming. If you could point me to somewhere to read about getting fopen to run my script instead of just grabbing its contents, I would be very grateful... Link to comment https://forums.phpfreaks.com/topic/126686-question-about-passthru-and-fopen/#findComment-655237 Share on other sites More sharing options...
sweetname Posted October 2, 2008 Author Share Posted October 2, 2008 I ended up deciding that it would be better to cache the resized images on disk and then opening them with fopen, but I never did get this to work without saving the image to disk and using fopen. I could get the same image in the browser using popen or proc_open but Ming didn't like either of those ways. Ming was only happy with fopen, so I don't know if it was something I was doing wrong or just something to do with ming... I am using v.3 and there is v.4.2 out now or something like that but I don't want to change it since it is working lol. Link to comment https://forums.phpfreaks.com/topic/126686-question-about-passthru-and-fopen/#findComment-655992 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.