Solved

Using PHP, how do I create a random collage of images, all of different sizes?

Posted on 2008-10-08
6
468 Views
Last Modified: 2013-12-25
I need to create a collage/cloud type page of all images. I have an array filled with 10 different size combinations. Check out the image i made of the random sizes and distribution that this script needs to produce. I am wondering if someone knows of where i can find a script to produce something like the image i attached, or if there are guiding principles (css float, position, etc) that i need to fool around with first. I apologize for how vague I am being.
cats.jpg
0
Comment
Question by:jonarc124
6 Comments
 
LVL 39

Expert Comment

by:Roger Baklund
ID: 22674579
You can use the PHP function imagecopyresampled() to copy and resize an image. You can resize multiple images (or multiple versions of the same image) into the same destination image.

http://php.net/manual/en/function.imagecopyresampled.php
0
 

Author Comment

by:jonarc124
ID: 22674613
The php script needs to automatically place the different images, not resize them to fit one specific collage layout.
0
 
LVL 29

Expert Comment

by:fibo
ID: 22676387
In the example you give:
- is it created from a single image, which is resized to fit? or is it supposed to be different images (minimum number?), each with a different size (which range of sizes?)
- Do you need taht all images somehow fill in the screen with no space, or is it totally random, eg as in the (blurred) capture attached?
screen-capture.jpg
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

Author Comment

by:jonarc124
ID: 22679291
Different images (list pulled from a db with each image having different dimensions) filling the screen with no/minimal space in between each.  They can either fill the page from top left to bottom right, or kind of "grow" from the center of the page outwards.
0
 
LVL 29

Accepted Solution

by:
fibo earned 500 total points
ID: 22693063
The optimum is a difficult algorithm. You might explore what is used for some machine tools which try to optimize how to "best" cut a set of pieces in a given dimension.

So you might consider which is your "second best" option, ie relax some constraints.

Interesting topological problem... explore mathematical sources...
0
 
LVL 4

Expert Comment

by:Lordgobbledegook
ID: 22711310
In regards to image manipulation, Imagemagick is very widely used and highly regarded.  Most web hosts have it installed as standard.

I have found this link invaluable when working with image manipulation:
http://www.imagemagick.org/Usage/thumbnails/
and for all the topics... http://www.imagemagick.org/Usage/

While not directly related, there is also some interesting reading at:
http://valokuva.org/

It could also be done using GD within PHP but after using Imagemagick I find it to be clunky and inefficient.  All the best!
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses four methods for overlaying images in a container on a web page
Any business that wants to seriously grow needs to keep the needs and desires of an international audience of their websites in mind. Making a website friendly to international users isn’t prohibitively expensive and can provide an incredible return…
In this tutorial viewers will learn how to style a decorative dropcap for the first letter in a paragraph using CSS. In CSS, create a new paragraph class by typing "p.fancy": Then, to style only the first letter of the first sentence, include the ps…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

809 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