PHP

Moderators: None (Apply to moderate this forum)
Number of threads: 1847
Number of posts: 5013

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Creating thumnails from .jpg files Posted by netgert on 24 Nov 2003 at 11:53 AM
Hi,

I need to create certain sized thumnails from a .jpg file that's in the same location as my .php file. The .php sould open the .jpg, create a thumnail and save it to the same place

NetGert[/italic]

Report
Re: Creating thumnails from .jpg files Posted by DarQ on 24 Nov 2003 at 12:06 PM
This message was edited by Moderator at 2003-11-24 12:6:55


here you can see the functions you might need for resizing thumbnails on the fly:
http://php.net/manual/ref.image.php

: Hi,
:
: I need to create certain sized thumnails from a .jpg file that's in the same location as my .php file. The .php sould open the .jpg, create a thumnail and save it to the same place
:
NetGert[/italic]

:

DarQ
url--> http://mark.space.servehttp.com



Report
Re: Creating thumnails from .jpg files Posted by netgert on 24 Nov 2003 at 12:18 PM
: This message was edited by Moderator at 2003-11-24 12:6:55

:
: here you can see the functions you might need for resizing thumbnails on the fly:
: http://php.net/manual/ref.image.php
:

: : Hi,
: :
: : I need to create certain sized thumnails from a .jpg file that's in the same location as my .php file. The .php sould open the .jpg, create a thumnail and save it to the same place
: :
NetGert[/italic]

: :
:
: DarQ
: url--> http://mark.space.servehttp.com
:
:
:
:
I need to create a thumbnail from the .jpg as a new file, not to return it to the browser. I can handle creating a dynamic image, but I want to read an image, resize it, and write it as a new image.

NetGert[/italic]


Report
Re: Creating thumnails from .jpg files Posted by DarQ on 24 Nov 2003 at 12:31 PM
This message was edited by Moderator at 2003-11-24 12:34:44

: : This message was edited by Moderator at 2003-11-24 12:6:55

: :
: : here you can see the functions you might need for resizing thumbnails on the fly:
: : http://php.net/manual/ref.image.php
: :

: : : Hi,
: : :
: : : I need to create certain sized thumnails from a .jpg file that's in the same location as my .php file. The .php sould open the .jpg, create a thumnail and save it to the same place

see
http://php.net/manual/function.imagejpeg.php
: : :
NetGert[/italic]

: : :
: :
: : DarQ
: : url--> http://mark.space.servehttp.com
: :
: :
: :
: :
: I need to create a thumbnail from the .jpg as a new file, not to return it to the browser. I can handle creating a dynamic image, but I want to read an image, resize it, and write it as a new image.

what you can display, you can save. is saving a file your problem?? then use fopen and fputs

:
NetGert[/italic]

:
:

DarQ
url--> http://mark.space.servehttp.com



Report
Re: Creating thumnails from .jpg files Posted by DarQ on 24 Nov 2003 at 12:35 PM
see
http://nl.php.net/manual/nl/function.imagejpeg.php



: This message was edited by Moderator at 2003-11-24 12:34:44

: : : This message was edited by Moderator at 2003-11-24 12:6:55

: : :
: : : here you can see the functions you might need for resizing thumbnails on the fly:
: : : http://php.net/manual/ref.image.php
: : :

: : : : Hi,
: : : :
: : : : I need to create certain sized thumnails from a .jpg file that's in the same location as my .php file. The .php sould open the .jpg, create a thumnail and save it to the same place
:
: see
: http://php.net/manual/function.imagejpeg.php
: : : :
NetGert[/italic]

: : : :
: : :
: : : DarQ
: : : url--> http://mark.space.servehttp.com
: : :
: : :
: : :
: : :
: : I need to create a thumbnail from the .jpg as a new file, not to return it to the browser. I can handle creating a dynamic image, but I want to read an image, resize it, and write it as a new image.
:
: what you can display, you can save. is saving a file your problem?? then use fopen and fputs
:

: :
NetGert[/italic]

: :
: :
:
: DarQ
: url--> http://mark.space.servehttp.com
:
:
:
:

DarQ
url--> http://mark.space.servehttp.com

Report
Re: Creating thumnails from .jpg files Posted by emperor on 25 Nov 2003 at 8:46 AM
This message was edited by emperor at 2003-11-25 9:37:10

: Hi,
:
: I need to create certain sized thumnails from a .jpg file that's in the same location as my .php file. The .php sould open the .jpg, create a thumnail and save it to the same place
:
NetGert[/italic]

:
(Now edited to include proper formatting on the code!)

To do this you need the GD graphics library - it comes bundled as standard with PHP 4.3.x, so if you have an older version of PHP either upgrade or check out http://www.boutell.com/gd for info on installing the GD library. You may need to recompile PHP for GD support (I did) - although PHP comes bundled with GD you'll still need to ./configure --with-gd --with-jpeg-dir etc. (I assume you're on a linux/unix-style OS, I'm not sure how to use GD on a Windows install).

Once you have that sorted, do this:

<?php
    $src = ImageCreateFromJPEG ($src_filename);

    $width = ImageSx ($src);
    $height = ImageSy ($src);
    $x = $desired_width;
    $y = $desired_height;

    $dst = ImageCreateTrueColor ($x, $y);
    ImageCopyResampled ($dst, $src, 0, 0, 0, 0, $x, $y, $width, $height);
    ImageJPEG ($dst, $dst_filename);    // or ImagePNG or whatever
?>


Note the function names do not need to be capitalised, I just write them that way to make them easier to read, they're all lowercase in the PHP manual.

Hope this helps




Report
Re: Creating thumnails from .jpg files Posted by netgert on 5 Dec 2003 at 8:23 AM
: This message was edited by emperor at 2003-11-25 9:37:10

: : Hi,
: :
: : I need to create certain sized thumnails from a .jpg file that's in the same location as my .php file. The .php sould open the .jpg, create a thumnail and save it to the same place
: :
NetGert[/italic]

: :
: (Now edited to include proper formatting on the code!)
:
: To do this you need the GD graphics library - it comes bundled as standard with PHP 4.3.x, so if you have an older version of PHP either upgrade or check out http://www.boutell.com/gd for info on installing the GD library. You may need to recompile PHP for GD support (I did) - although PHP comes bundled with GD you'll still need to ./configure --with-gd --with-jpeg-dir etc. (I assume you're on a linux/unix-style OS, I'm not sure how to use GD on a Windows install).
:
: Once you have that sorted, do this:
:
:
<?php
:     $src = ImageCreateFromJPEG ($src_filename);
: 
:     $width = ImageSx ($src);
:     $height = ImageSy ($src);
:     $x = $desired_width;
:     $y = $desired_height;
: 
:     $dst = ImageCreateTrueColor ($x, $y);
:     ImageCopyResampled ($dst, $src, 0, 0, 0, 0, $x, $y, $width, $height);
:     ImageJPEG ($dst, $dst_filename);    // or ImagePNG or whatever
: ?>

:
: Note the function names do not need to be capitalised, I just write them that way to make them easier to read, they're all lowercase in the PHP manual.
:
: Hope this helps
:
:
:
:
:
This code gives me an error saying that imagecreatefromjpeg is undefined. I assume this is because GD library is not installed. I have PHP 4.3.4. Doesn't GD come with that? I downloaded GD library but can't get it to be used by PHP. Any ideas?

NetGert[/italic]


Report
Re: Creating thumnails from .jpg files Posted by DarQ on 5 Dec 2003 at 8:53 AM
: : This message was edited by emperor at 2003-11-25 9:37:10

: : : Hi,
: : :
: : : I need to create certain sized thumnails from a .jpg file that's in the same location as my .php file. The .php sould open the .jpg, create a thumnail and save it to the same place
: : :
NetGert[/italic]

: : :
: : (Now edited to include proper formatting on the code!)
: :
: : To do this you need the GD graphics library - it comes bundled as standard with PHP 4.3.x, so if you have an older version of PHP either upgrade or check out http://www.boutell.com/gd for info on installing the GD library. You may need to recompile PHP for GD support (I did) - although PHP comes bundled with GD you'll still need to ./configure --with-gd --with-jpeg-dir etc. (I assume you're on a linux/unix-style OS, I'm not sure how to use GD on a Windows install).
: :
: : Once you have that sorted, do this:
: :
: :
<?php
: :     $src = ImageCreateFromJPEG ($src_filename);
: : 
: :     $width = ImageSx ($src);
: :     $height = ImageSy ($src);
: :     $x = $desired_width;
: :     $y = $desired_height;
: : 
: :     $dst = ImageCreateTrueColor ($x, $y);
: :     ImageCopyResampled ($dst, $src, 0, 0, 0, 0, $x, $y, $width, $height);
: :     ImageJPEG ($dst, $dst_filename);    // or ImagePNG or whatever
: : ?>

: :
: : Note the function names do not need to be capitalised, I just write them that way to make them easier to read, they're all lowercase in the PHP manual.
: :
: : Hope this helps
: :
: :
: :
: :
: :
: This code gives me an error saying that imagecreatefromjpeg is undefined. I assume this is because GD library is not installed. I have PHP 4.3.4. Doesn't GD come with that? I downloaded GD library but can't get it to be used by PHP. Any ideas?


http://php.net/manual/ref.image.php

all gdlib information you will need. the first link on the page is a link to the creator of gdlib, and whats the first thing you see on the site? a php gdlib patch (Patching PHP 4.2.3 for gd 2.0.8 and Up).
good luck

:
NetGert[/italic]

:
:

DarQ
url--> http://mark.space.servehttp.com

Report
Re: Creating thumnails from .jpg files Posted by emperor on 5 Dec 2003 at 8:54 AM
: This code gives me an error saying that imagecreatefromjpeg is undefined. I assume this is because GD library is not installed. I have PHP 4.3.4. Doesn't GD come with that? I downloaded GD library but can't get it to be used by PHP. Any ideas?

GD comes bundled with PHP 4.3.x but you need to give the configure script the following options:
./configure --with-gd --with-jpeg-dir

in order for it to compile the GD library with its jpeg functions.
Report
Re: Creating thumnails from .jpg files Posted by netgert on 5 Dec 2003 at 9:39 AM
: : This code gives me an error saying that imagecreatefromjpeg is undefined. I assume this is because GD library is not installed. I have PHP 4.3.4. Doesn't GD come with that? I downloaded GD library but can't get it to be used by PHP. Any ideas?
:
: GD comes bundled with PHP 4.3.x but you need to give the configure script the following options:
:
: ./configure --with-gd --with-jpeg-dir
: 

: in order for it to compile the GD library with its jpeg functions.
:
I can't find the place for that in the php.ini not is there an executable named configure. Oh and I'm using Windows XP Pro and Apache.

NetGert[/italic]


Report
Re: Creating thumnails from .jpg files Posted by netgert on 5 Dec 2003 at 10:42 AM
: : : This code gives me an error saying that imagecreatefromjpeg is undefined. I assume this is because GD library is not installed. I have PHP 4.3.4. Doesn't GD come with that? I downloaded GD library but can't get it to be used by PHP. Any ideas?
: :
: : GD comes bundled with PHP 4.3.x but you need to give the configure script the following options:
: :
: : ./configure --with-gd --with-jpeg-dir
: : 

: : in order for it to compile the GD library with its jpeg functions.
: :
: I can't find the place for that in the php.ini not is there an executable named configure. Oh and I'm using Windows XP Pro and Apache.
:
NetGert[/italic]

:
:
Got it working. I'm using NuSphere TechPlatform which contains Apache, PHP and Perl and there are multiple php.ini files and I modified the wrong one (in /php/, real one used was in /apache/).
Thank you all for your help

NetGert[/italic]





 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.