SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    Not Bad, eh? Justin Sampson's Avatar
    Join Date
    Aug 2000
    Location
    N.S., Canada
    Posts
    487
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey,
    Is there anyway to compress images using PHP. I don't mean to resize them, I want to make the file size smaller.

    Thanks,
    Justin Sampson

  2. #2
    SitePoint Addict
    Join Date
    Jul 2000
    Location
    North Central AR
    Posts
    231
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could do it with GD. GD is a image libary/add-on for php among other lanuages. It can be used to resize, like thumbs, reduce resolution and more.

    http://www.boutell.com/gd/

    Now getting it to work locally is another thing, I still have'nt. It comes with most php versions, but I have yet to get it working. Maybe some one else could help with getting it running. If your hosted, ask your host, they should be able to set it up no poblem.

    Another package is ImageMagick. I've used it to reduce size, but not sure about resolution.

    http://www.imagemagick.org/

    Hope that helps.

    ronnie
    The largest selection of PLR Articles on the Planet!
    Many Private Label Rights Products.

  3. #3
    ********* wombat firepages's Avatar
    Join Date
    Jul 2000
    Location
    Perth Australia
    Posts
    1,717
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you are working on a unix box you can use cjpeg to compress the files, but first you have to decompress them - at least I never tried compressing a jpeg itself ?

    ie:

    exec("djpeg -colours 256 -ppm $file > $file.pnm");//decompress to .pnm
    exec("cjpeg -quality 50 $file.ppm > $file");//recompress with -quality 50 - or whatever.
    unlink("$file.ppm");//get rid of .ppm

    note that $file is the path to the file ie '$DOCUMENT_ROOT/directory/this.jpg'
    Last edited by firepages; Mar 17, 2001 at 01:11.

  4. #4
    Not Bad, eh? Justin Sampson's Avatar
    Join Date
    Aug 2000
    Location
    N.S., Canada
    Posts
    487
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks!

    I should have said that I wanted to compress gif's, anyone know how to do that?

  5. #5
    ********* wombat firepages's Avatar
    Join Date
    Jul 2000
    Location
    Perth Australia
    Posts
    1,717
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not sure you can - you can turn them into a jpeg using giftoppm()/cjpeg() etc - but then they aint gifs no more.

  6. #6
    Not Bad, eh? Justin Sampson's Avatar
    Join Date
    Aug 2000
    Location
    N.S., Canada
    Posts
    487
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think I might use ImageMagick but I can't find a single tutorial on how to use it. Anyone know of any tutorials for it?

    Thanks,
    Justin Sampson

  7. #7
    SitePoint Addict
    Join Date
    Jul 2000
    Location
    North Central AR
    Posts
    231
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here's how freddy explained it to me, running it in windows, locally from the command line:

    http://www.sitepointforums.com/showt...ht=imagemagick

    As far as a tutorial, there should be everything you need at the imagemagick site. With Freddy's help I installed it no problem, but have'nt tried reducing image resolution yet.

    Sorry i can't be more help, maybe some one else has had more experience with it. You might also check out script sites, sure there are plenty of examples.

    ronnie
    The largest selection of PLR Articles on the Planet!
    Many Private Label Rights Products.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •