Git Product home page Git Product logo

mosaic-generator's Introduction

Mosaic generator using PHP, GD, MySQL

I initially wrote this class was for my personal use. It has been designed to process a large amount of pictures, and generate a mosaic of a specific photo. I have used this script to generate very high quality mosaics, that were printed out as posters. Processing time can take a while, but it's worth it!

A MySQL database is needed to store thumbnail information (especially if you have thousands of pictures).

This is what an outpout looks like:

demo

256 rows and 256 columns. 10.000 pictures were used

Installation

  1. Make sure you have PHP 5, GD and MySQL installed.

  2. Create the appropriate database setup

	CREATE DATABASE `mosaic`;

	USE `mosaic`;

	CREATE TABLE IF NOT EXISTS `thumbnails` (
	  `filename` varchar(255) NOT NULL,
	  `red` smallint(6) NOT NULL,
	  `green` smallint(6) NOT NULL,
	  `blue` smallint(6) NOT NULL
	);
  1. Copy as many different pictures as you can to ./photos (at least a few hundreds)

  2. Modify variables from Mosaic.php to your needs (especially database info)

Usage

From command line:

$ ./cl-script.php --input {filename} --rows {int} --columns {int} [--thumbs]

--input                  path to the original picture that shall be recreated
--rows                   number of thumbnails to create per row
--columns                number of thumbnails to create per column
--no-thumbs (optional)   won't (re)generate thumbnails before creating mosaic.

...Directly from class:

	$ouput_filename = new Mosaic(string $input_filename, int $rows, int $columns [, bool $gen_thumbs = true ] );

Troubleshoot

You may need to tweak your php config and increase max_execution_time and/or memory_limit if you're not using cl-script.php.

mosaic-generator's People

Contributors

eflorit avatar uintaam avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.