is it possible to do this? (resize image from url only)

This is a discussion on is it possible to do this? (resize image from url only) within the PHP Language forums, part of the PHP Programming Forums category; I am struggling to create a PHP function that would take a specified image (JPG, GIF or PNG) from a ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-20-2005
Julia Briggs
 
Posts: n/a
Default is it possible to do this? (resize image from url only)

I am struggling to create a PHP function that would take a specified
image (JPG, GIF or PNG) from a link, and resize it down to a thumbnail
so it will always fit in a 200x250 space. I am hoping not to have it
inserted or read from a database to do this function. Can it be done &
someone please help me?

Reply With Quote
  #2 (permalink)  
Old 02-20-2005
Schraalhans Keukenmeester
 
Posts: n/a
Default Re: is it possible to do this? (resize image from url only)

Julia Briggs wrote:
> I am struggling to create a PHP function that would take a specified
> image (JPG, GIF or PNG) from a link, and resize it down to a thumbnail
> so it will always fit in a 200x250 space. I am hoping not to have it
> inserted or read from a database to do this function. Can it be done &
> someone please help me?
>

You could simply write out a <img src="http://othersite.com/image.jpg
width="200" height="250"> tag, but this is
a) not very nice to the people whose site you deeplink too (sometimes
not even allowed/possible), and
b) it would mean for displaying only a thumbnail the full image has to
be loaded by the client.

The decent thing would be to load the pic (if allowed), resize it using
GD or Imagamagick library functions and store it on your own server.
Thus it's resized only once and you take responsibility for the
bandwidth your site incurs.

There are ways of making thumbnails without addon libs, see
http://www.sitepoint.com/forums/arch...p/t-57426.html for
instance. Heed the warning: these algorithms appear to be very SLOW.

PHP manual might also help you further...
HTH
SH

Reply With Quote
  #3 (permalink)  
Old 02-21-2005
Geoff Berrow
 
Posts: n/a
Default Re: is it possible to do this? (resize image from url only)

I noticed that Message-ID:
<1108934337.823051.28370@f14g2000cwb.googlegroups. com> from Julia Briggs
contained the following:

>I am struggling to create a PHP function that would take a specified
>image (JPG, GIF or PNG) from a link, and resize it down to a thumbnail
>so it will always fit in a 200x250 space. I am hoping not to have it
>inserted or read from a database to do this function. Can it be done &
>someone please help me?


As SH has said, it's better to do this just once. Also bear in mind
that not all pictures will share the same aspect ratio. To maintain
this, you can either pick width or height, but not both.

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Reply With Quote
  #4 (permalink)  
Old 02-21-2005
Julia Briggs
 
Posts: n/a
Default Re: is it possible to do this? (resize image from url only)

Thanks Geoff & SK -- is it possible to somehow load the original image,
and store it into a 'virtual one time session blob variable' (pls
forgive me for my crude wordiness, but conceptually this is what I
imagine)... and then resize the width first, and after its resized,
then apply a second resizing for the height (so this ensures all images
no matter what will fit into a 200 x 250 space). I don't know the full
extent of what's possible with PHP... but can you work this way without
a database? All my images will be fairly small, but I'm working in a
very restrictive server space limitation, so don't want to store an
extra thumbnail image in the database if all possible.






Schraalhans Keukenmeester wrote:
> Julia Briggs wrote:
> > I am struggling to create a PHP function that would take a

specified
> > image (JPG, GIF or PNG) from a link, and resize it down to a

thumbnail
> > so it will always fit in a 200x250 space. I am hoping not to have

it
> > inserted or read from a database to do this function. Can it be

done &
> > someone please help me?
> >

> You could simply write out a <img src="http://othersite.com/image.jpg


> width="200" height="250"> tag, but this is
> a) not very nice to the people whose site you deeplink too (sometimes


> not even allowed/possible), and
> b) it would mean for displaying only a thumbnail the full image has

to
> be loaded by the client.
>
> The decent thing would be to load the pic (if allowed), resize it

using
> GD or Imagamagick library functions and store it on your own server.
> Thus it's resized only once and you take responsibility for the
> bandwidth your site incurs.
>
> There are ways of making thumbnails without addon libs, see
> http://www.sitepoint.com/forums/arch...p/t-57426.html for
> instance. Heed the warning: these algorithms appear to be very SLOW.
>
> PHP manual might also help you further...
> HTH
> SH


Reply With Quote
  #5 (permalink)  
Old 02-21-2005
Geoff Berrow
 
Posts: n/a
Default Re: is it possible to do this? (resize image from url only)

I noticed that Message-ID:
<1108947954.003500.67010@c13g2000cwb.googlegroups. com> from Julia Briggs
contained the following:

>Thanks Geoff & SK -- is it possible to somehow load the original image,
>and store it into a 'virtual one time session blob variable' (pls
>forgive me for my crude wordiness, but conceptually this is what I
>imagine)... and then resize the width first, and after its resized,
>then apply a second resizing for the height (so this ensures all images
>no matter what will fit into a 200 x 250 space). I don't know the full
>extent of what's possible with PHP... but can you work this way without
>a database? All my images will be fairly small, but I'm working in a
>very restrictive server space limitation, so don't want to store an
>extra thumbnail image in the database if all possible.


Well thumbnails won't take much space and what most people do is store
filenames in databases rather than the files themselves.

But rather than resize twice, what I'd do is get the image dimensions
and then use logic to determine whether to resize on height or width.

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 10:56 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0