SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Zealot
    Join Date
    Sep 2000
    Location
    Seattle, WA area
    Posts
    104
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi everybody!

    I am currently in the process of designing the content management system for my site. I need the ability to upload images, make a thumbnail for them and then save both the URL for the thumbnail and the full-sized image to the database. Here's my database structure:

    TABLE: Images
    ID (AUTO INCREMENT)
    ImageTitle
    ImageCaption
    ImageURL (for the full-sized image)
    ImageThumbnailURL
    SID (Story-ID)

    The form will send all the information (with the exception of ImageURL and ImageThumbnailURL as the former is sent via the form as the actual file and the latter needs to be created).

    I want the thumbnail to be 198 x 198. Let me know if any more info is needed.

    Thanks in advance to all the wonderful people here.

  2. #2
    ********* wombat firepages's Avatar
    Join Date
    Jul 2000
    Location
    Perth Australia
    Posts
    1,717
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the main hurdle is the resizing of the image, if you are running under *nix you can probably do something like this... (to an image uploaded via file called $uploadtemp)

    exec("djpeg -colours 256 -ppm $uploadtemp > $uploadtemp.ppm");
    exec("pnmscale -xysize 300 300 $uploadtemp.ppm > $uploadtemp.small.ppm");
    exec("pnmscale -xysize 198 198 $uploadtemp.ppm > $uploadtemp.smaller.ppm");
    exec("cjpeg -quality 90 $uploadtemp.small.ppm > $final");
    exec("cjpeg -quality 90 $uploadtemp.smaller.ppm > $smallfinal");

    you then have to remove the .ppm's either with unlink() or via shell.
    (there are easier ways but the unix box my site is on does not have the full set of image functions(among other things))

    Or check out if your host has imageMagick on the system which is really funky!

  3. #3
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah ImageMagick is the ticket you can copy the uploaded image to a folder twice naming the second one "thumb".$nameofuploadedfile_name


    then issue

    exec("mogrify -geometry 198x198! /pathto/$imagename");


    Works with gifs, jpegs and pngs
    <Edited by freddydoesphp on 01-27-2001 at 09:08 PM>
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  4. #4
    SitePoint Zealot
    Join Date
    Sep 2000
    Location
    Seattle, WA area
    Posts
    104
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have sent an email to my host asking if they have ImageMagick...I should get a response from them in a couple of hours. With ImageMagick, would it be possible to put my logo (a transparent gif file)over the full-sized images?

    I'm still looking for good ways to do this, so I'll take any solutions. Thanks

  5. #5
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Most defintely it comes with some docs that will tell you how to do all that. If your host deons't have it, you can pre compiled binaries, which you can probably upload to folder where you can have execute privileges, outside the web root and use it that way, but I am not entirely sure if that will work you may have to give it a try.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  6. #6
    SitePoint Zealot
    Join Date
    Sep 2000
    Location
    Seattle, WA area
    Posts
    104
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, my host says that they don't have ImageMagick installed, but I'm free to install it myself. I'll be installing tomorrow. I guess I get to look through their pages upon pages of docs. Fun! Thanks for all your help.


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
  •