?
Solved

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

Posted on 2008-10-08
6
Medium Priority
?
619 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Get MongoDB database support online, now!

At Percona’s web store you can order your MongoDB database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card. Handle your MongoDB database support now!

 

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 2000 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Australian government abolished Visa 457 earlier this April and this article describes how this decision might affect Australian IT scene and IT experts.
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
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.
Suggested Courses

743 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