[Phpwm] displaying images on screen
Daniel Davies
daniel at sitedesign.net
Thu Oct 2 14:43:47 UTC 2008
Hi Alan, if I understand correctly what you're trying to achieve is not
possible really. A separate http request is always required to display
an image within a page, generated by PHP or not. The examples you've
been given will still need your page to include an <img> tag pointing
the script thats displaying your rotated jpeg - just using the examples
you won't need to actually write that image to disk.
Just on a sidenote; if you're likely to rotate the same images from the
archive several times then writing to disk will actually save you
overhead as once you've rotated an image it won't need to be processed
through GD again. i.e. img001.jpg can be saved as img001_rotated_90.jpg
the first time it gets rotated. Next time you have a request to rotate
image001.jpg you see if the img001_rotate_90.jpg exists. If it is does
then you just link to that and avoid the quite intense processing of
graphics.
Regards,
Daniel
alan dunn wrote:
> Thanks so far - I didn't get all the question correct! We agree about
> how to put the image to the page. The problem (I now understand) is that
> we want to show it as a pop-up within an existing page, so the header
> line is already set: content="text/html; "
>
> What this does is cause the image to display as text.
>
> thanks again, alan
>
> BinaryKitten wrote:
>
>> alan dunn wrote:
>>
>>
>>> This probably has an easy answer, but we haven't found it.
>>>
>>> We have an archive of jpeg images. We want to open one using GD library
>>>
>>> $im1 = imagecreatefrom jpeg($pathname.$filename);
>>>
>>> rotate it:
>>>
>>> $im1 = imagerotate($im1,-90,0); .... and display it on screen.
>>>
>>> How do we get to display the image which is now represented by resource
>>> $im1?
>>> We know you can do it by saving the rotated image back to somewhere then
>>> displaying the saved image - but that's a lot of overhead just to show a
>>> temporarily rotated image.
>>>
>>> Any help much appreciated, thanks, Alan Dunn
>>>
>>>
>>>
>>>
>>>
>> as you've created a jpeg resource, you will need to output the header
>> that you are ouputing a jpeg instead of the standard html.. to do this
>> use the following snippet:
>>
>> header("Content-type: image/jpeg");
>>
>> then call upon the imagejpeg function passing $im1 to it like so:
>> imagejpeg($im1);
>>
>> you can also save to a file if you want, again using hte imagejpeg function
>> imagejpeg($im1, "/path/filename.jpg")
>>
>> as well as choose the quality level you want to ouput
>> imagejpeg($im1, null,(0-100)) // Output to screen @ quality level
>> imagejpeg($im1, "/path/filename.jpg", (0-100))
>> // Output to file @ quality level
>>
>> the default quality level is 75.
>>
>> Finally don't forget to call imagedestroy($im1) afterwards to clean up
>> the memory...
>>
>> Kat
>>
>>
>> _______________________________________________
>> Phpwm mailing list
>> Phpwm at mailman.lug.org.uk
>> https://mailman.lug.org.uk/mailman/listinfo/phpwm
>>
>>
>>
>>
>
>
--
Daniel Davies
Sitedesign.net Ltd
Birchley House
Birchfield Lane
Oldbury
West Midlands
B69 1DT
Tel: 0121 543 4840
Fax: 0121 543 4841
http://www.sitedesign.net
More information about the Phpwm
mailing list