Solved

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

Posted on 2008-10-08
6
530 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Today it’s fairly well known that high-performing websites and applications bring in more visitors, higher SEO, and ultimately more sales. By the same token, downtime is disastrous for companies and can lead to major hits on a brand, reputation, an…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

733 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