Solved

List Images in specified size

Posted on 2000-04-21
5
187 Views
Last Modified: 2006-11-17
Ok. I've messed with my PHP since yesterday ( I'm a beginner ) so I need your help.

I've succesfully made an upload image php script which stores images in a folder eg /home/bazet/photos
The images are random from jpg to gif. What I want is, just a page that list all the images in that folder in thumbnails ( 100 px X 100 px ) and when clicked ..it will display the real one. And I would like to display it in order ( rows ) and sorted by date .

Can you give me an example ?
0
Comment
Question by:bazet
  • 2
  • 2
5 Comments
 

Expert Comment

by:mrvithan
ID: 2737268
I amn't quite sure i understand your question... but if i did. You could make thumbnails by using HTML.
 
with sorting by date, using filemtime function to get last modified date is a idea, and use them to be a index. but i don't know the return value from filemtime is a timestamp or a complete day. You just try it.
0
 
LVL 8

Expert Comment

by:us111
ID: 2737971
The following works, it sorts by date and 100*100 pixels

<?
  $handle=opendir(".");

  // create an array
  while ($file = readdir($handle))
  {      if ((strstr($file, ".gif") <> false) || (strstr($file, ".jpg") <> false))
          $pictarray[] = filemtime($file)."~~".$file;
      }

      // sort by date
    sort($pictarray);
    for($i=0; $i<count($pictarray);$i++)
    {      $file = split("~~", $pictarray[$i]);
        $file = $file[1];
?>
        <a href="<?print $file?>"><img src="<?print $file?>" height="100" width="100" border="0"></a><br>
<?
        }
        closedir($handle);
?>
0
 

Expert Comment

by:mrvithan
ID: 2738335
Opp...... I have to study how people give some answer from us111.... :)
0
 

Accepted Solution

by:
benchun earned 50 total points
ID: 2812223
from http://www.faqts.com/

You can display an image as a different size just by setting the height
and width properties in the HTML IMG tag.  This results in the complete
file being downloaded regardless of the final image size however.  That
can make for some very large thumbnails...<g>

To adjust the image file size as well you'll need to install this lib on
your machine : Image Magick, it can be found at

    http://www.wizards.dupont.com/cristy/ImageMagick.html

Here's a quick run down from their web site:
    ImageMagickTM, version 4.2.8, is a robust collection of tools and
    libraries to read, write, and manipulate an image in any of the more
    popular image formats including GIF, JPEG, PNG, PDF, and Photo CD.
    With ImageMagick you can create GIFs dynamically making it suitable
    for Web applications.

    You can also resize, rotate, sharpen, color reduce, or add special
    effects to an image and save your completed work in the same or
    differing image format.

    Here are just a few examples of what ImageMagick can do:
         * Convert an image from one format to another (e.g. TIFF to
           JPEG)
         * Resize, rotate, sharpen, color reduce, or add special effects
           to an image
         * Create a montage of image tumbnails
         * Create a transparent image suitable for use on the Web
         * Turn a group of images into a GIF animation sequence
         * Create a composite image by combining several separate images
         * Draw shapes or text on an image
         * Decorate an image with a border or frame
         * Describe the format and characteristics of an image

The X11 libs are only required if you build the full ImageMagick
package, including the graphic viewer.  If all you're interested in is
the command-line tools, you can 'configure --without-x'

Once you install the neccessary libs, you will have a program called
"mogrifycation" which you can run from the command line. You can do all
sorts of img manipularion with this util ie resize, dither, reduce
resolution etc etc from the command line :).

So you could easily use the PHP system() call to execute the command and
get what you want.

0
 
LVL 8

Expert Comment

by:us111
ID: 2813347
????????????????
Strange answer for the question.

I don't think you will have a powerfull php application with imageMagick.
ImageMaGick will be call by exec or system command in PHP script...

Well why not.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Responsive Design Tools 6 40
Button Click 11 26
Phone Dialer 5 38
PHP json decode 9 26
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now