16
"Let's face it, aligned images are like little gifts from Heaven. Welcome, but unexpected." - Geobits
+10000 reputation to whoever wins this challenge.
Rules:
1) You are to generate a program.
2) Input will be an image, however whether it is passed as a file or a list of numbers is up to you.
3) Output will be a file which when opened in paint (or similar) will show the image aligned.
4) The canvas size will always be between 100 x 100 and 2000 x 2000 pixels. It will always be a rectangle, but not always a square.
5) No hard coding of images or funky URL magic.
6) No external libraries to be used.
Guide to Centralisation (Joshpbarron Variant)
An image will be defined as centered if the 1st white(255,255,255,>0 rgba) or transparent(x,y,z,0 rgba) on an axis is equal distance (plus or minus 1 pixel) from the edge of the canvas.
This can be achieved (and will be verified by) the following method.
1) Imagine a bounding box around the object. (Black lines added for help)
2) Move the object around until the edge of the object is equal distance from the appropriate edge of the canvas.
3) Now forget the black lines.
Input:
Output:
More inputs here.
And respective outputs here.
The +10000 rep is a lie.
should the program handle completely white/transparent images? – Cristian Lupascu – 2015-05-06T09:23:22.310
As there is nothing to center, the same image should be returned. Same for images with no empty space. – Joshpbarron – 2015-05-06T09:39:20.373
You should add some specifics on the images that this should work for. For example should it work for an image that contains a mostly white background but has holes of transparency? Or does having transparency mean there will be no white, and vice versa. – bubalou – 2015-05-07T15:06:14.630
Sorry, but the explanation is obvious. RBGA codes are given. – Joshpbarron – 2015-05-07T18:34:51.433
In the description, you talk about the distance of the 1st white/transparent pixel from an edge. Don't you mean the first non-white? Otherwise all the sample inputs are already solutions, because the distance of the first white pixel from each edge is 0, so those distanced are all equal. – Reto Koradi – 2015-06-06T15:33:50.050