473,837 Members | 1,622 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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?

Jul 17 '05 #1
4 14477
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

Jul 17 '05 #2
I noticed that Message-ID:
<11************ *********@f14g2 000cwb.googlegr oups.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/
Jul 17 '05 #3
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


Jul 17 '05 #4
I noticed that Message-ID:
<11************ *********@c13g2 000cwb.googlegr oups.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/
Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2463
by: DH | last post by:
I have a "file upload form" that works OK, but I have been unsuccessful in my attempt to also resize the uploaded .JPG (if it is too wide), over-writing the original .JPG, and then create and save a thumbnail.jpg .... all at the same time. Links to a working example would be appreciated. Thanks.
4
18606
by: SlasherStanley | last post by:
BlankHi How do you resize a jpg file. I want to open a file (c:\abc.jpg 800 x 600) and resize it as 120 x 100, I then want to save it as c:\abc_t.jpg. Thanks Slasher
2
1738
by: J'son | last post by:
Guys, I have built an application for a client that allows people to list their products for sale along with a photo of the product. If the photo is too big, I currently resize it down when the image is uploaded and store it in the database. My client now thinks the images are too small and needs to be resized. I can change the resize height/weight (settings in web.config), but since the resize happens only once on upload - all the...
8
36370
by: Lad | last post by:
Is it possible to change a picture resolution with Python? Let's say I have a picture with a resolution of 96 dpi and I would like to increase to 256dpi or higher. Thank you for your reply. LL
8
2350
by: Robert S | last post by:
I am writing an image viewer. I want to be able to resize the image so that it always fits within a window of given height and width. I've tried a couple of these from the web, but the don't seem to take into account both the image dimensions AND the window dimensions. Are there any algorithms out there? I'm not keen on reinventing the wheel here.
2
2522
by: Tim Arnold | last post by:
Hi, I'm using the Image module to resize PNG images from 300 to 100dpi for use in HTML pages, but I'm losing some vertical and horizontal lines in the images (usually images of x-y plots). Here's what I do: import Image def imgResize(self,filename): img = Image.open(filename) dpi = img.info.get('dpi') if dpi and 295 < int(dpi) < 305:
8
9437
by: infoseekar | last post by:
Image Resize & Rotation Hi I have 2 scripts, one for Image rotation and other image resize and they both are working. Image resize scripts load the picture and resize it and Image rotation rotate the image by 90 deg. They are two differennt files i.e. resize.php and rotate.php. What I want to do is to combine both rotate.php & resize.php files, so when the script resized the image than it will call rotate script to rotate the...
4
3880
by: Ty | last post by:
Hello all, I am creating a web site with Visual Stuido 2008. I am trying to use a java script file to create a busybox for login from this page http://blogs.crsw.com/mark/articles/642.aspx. I am using a master page senerio. The erro I'm getting is 'busyBox' is not a member of 'ASP.login2_aspx'
22
4986
by: simon2x1 | last post by:
i have an image which width is 213 and height is 200 when i echo the image and i resize it echo "<img src='company/$present' width='70' height='68'/>"; the image was not as clear as when it was 213 * 200.how can i make the image clear after i have resize it to 70 * 200.
0
9833
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9682
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10617
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10263
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9391
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6989
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5666
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5842
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4469
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.