Using ImageMagick

Talk about development tools here

Moderator: BigEvilCorporation

r57shell
Very interested
Posts: 478
Joined: Sun Dec 23, 2012 1:30 pm
Location: Russia
Contact:

Post by r57shell » Mon Jun 10, 2013 6:58 pm

ppm install was successful?
Which dll is missing?

Edit: My version of script.
frederic, what different clustering algo instead of K-means can be used? And may be use another tile representation for clustering?
Image

Ti_
Very interested
Posts: 82
Joined: Tue Aug 30, 2011 7:50 am

Post by Ti_ » Tue Jun 11, 2013 3:37 pm

r57shell wrote:ppm install was successful?
Which dll is missing?
CORE_RL_magick_.lib

I've used Frederick's method, now all works fine, that it:
- Uninstall Perl & ImageMagick (may not be necessary but it's what I did).
- Install Strawberry Perl 5.16.3.1
- Run the command line interface (cmd).
- Type cpan (it should give you a shell).
- Type install Algorithm::Cluster (it will download and compile the module, it may download a C compiler and dmake if needed).
- You can close the command line interface.

Then

- Download ImageMagick and run the installer.
- The installer will ask you to select/unselect a few options. Check "Add application directory to the system path" and "Install developpement headers and librairies for C and C++". Do not check "Install PerlMagick for ActiveState".
- Complete the installation.

Then

- Download PerlMagick here: http://search.cpan.org/CPAN/authors/id/ ... .86.tar.gz
- Uncompress the archive.
- Run a command line interface (cmd).
- Change directory to the folder you got from uncompressing the PerlMagick archive.
- Type "perl Makefile.PL". It may complain about "No library found for -lMagickCore-Q16"
- Edit the file named Makefile (in the same directory).
- Inside this file, find a line that begins with "LDLOADLIBS = ....."
- At the end of this line, add a space, then add -lCORE_RL_Magick_
- Save the file.
- In the command line interface, in the directory where the Makefile is, type dmake and then dmake install
- You're done.

A bug in PerlMagick prevents you from installing the module by typing "install Image::Magick" under the cpan shell. Without this bug, it would that easy.

Re-download my script (that has been modified to run under Windows). You should be able to use it.

Just checks Frederick's - bitmap2md.pl - it's output dithered file, without dither, with 58 colors from 60 :o

R57Shell:
Your script also works, without dither and make 40 colors.
With dither also 40, but your dither have too many dots.

You must add a tilemap to output, I don't know how may be used current asm.
It contain tiles, and pal. But no map, PAL ids - is commentaries.
Last edited by Ti_ on Tue Jun 11, 2013 3:45 pm, edited 2 times in total.

r57shell
Very interested
Posts: 478
Joined: Sun Dec 23, 2012 1:30 pm
Location: Russia
Contact:

Post by r57shell » Tue Jun 11, 2013 3:40 pm

Ti_ wrote:Your script also works, without dither and make 40 colors.
With dither also 40, but your dither have too many dots.
How many times I need to explain this bug of ImageMagick?
r57shell wrote: It will be better, if Remap dither was equal to Quantize dither in ImageMagick. But, it's not true, I don't know why.
What I mean:

Code: Select all

convert my_img.png -dither Riemersma -colors 30 my_img1.png
convert my_img.png -dither Riemersma -remap my_img1.png my_img2.png
my_img2 will have much more noise than my_img1.
Image

frederic
Interested
Posts: 23
Joined: Tue May 28, 2013 7:32 pm
Location: France

Post by frederic » Tue Jun 11, 2013 7:03 pm

r57shell wrote:frederic, what different clustering algo instead of K-means can be used? And may be use another tile representation for clustering?
Algorithm::Cluster provides several algorithms (k-means, k-median, k-medoids...). I tried k-median and it gave better results in some cases. You can try to play with the different algorithms and their parameters. I know nothing about these algorithms, I just found k-means when searching for a method to sort the tiles into groups. I tried it and it seemed to correctly sort the tiles in most cases, so I settled for it. You can also try to create the vectors differently. I create them using the RGB values of the pixels in each tile, but I tried to use the HSV values (after doing the RGB -> HSV conversion) and it gave different results.
Ti_ wrote:I've used Frederick's method, now all works fine
Glad to hear that.
Ti_ wrote:You must add a tilemap to output, I don't know how may be used current asm.
It contain tiles, and pal. But no map, PAL ids - is commentaries.
The output file is meant to be parsed by a script of yours. It should be easy to make a short script that can convert this into what you want. The tiles are given from left to right and top to bottom, starting at tile #0. I'll try to add a better output format.

bastien
Very interested
Posts: 208
Joined: Mon Jun 25, 2007 7:19 pm
Location: Besançon,France
Contact:

Post by bastien » Wed Jun 12, 2013 7:16 pm

hi,
I want to test the R57 modification script but when i launch the script i have this error :

Image

When i try to install it with cpan ( Frederic Method )

Code: Select all

Type cpan (it should give you a shell).
- Type install Algorithm::Cluster (it will download and compile the module, it may download a C compiler and dmake if needed). 
It will show me this error (SGDK gcc conflict ?)

Image

Thanks

r57shell
Very interested
Posts: 478
Joined: Sun Dec 23, 2012 1:30 pm
Location: Russia
Contact:

Post by r57shell » Wed Jun 12, 2013 7:20 pm

Delete temporarily GDK paths from PATH.

Code: Select all

echo %PATH%
save somewhere
and

Code: Select all

SET PATH=<all without GDK path>
and try compile again.
add GDK path again.
Image

bastien
Very interested
Posts: 208
Joined: Mon Jun 25, 2007 7:19 pm
Location: Besançon,France
Contact:

Post by bastien » Wed Jun 12, 2013 7:54 pm

Yeah !
Now it works thanks you very much for the fast reply :twisted:

r57shell
Very interested
Posts: 478
Joined: Sun Dec 23, 2012 1:30 pm
Location: Russia
Contact:

Post by r57shell » Wed Jun 12, 2013 8:48 pm

Added new option "tiles" to select global/local dither.
http://pastebin.com/XNUUMNgi
from left to right: global (old), local (new, default).
Image Image
Image

djcouchycouch
Very interested
Posts: 683
Joined: Sat Feb 18, 2012 2:44 am

Post by djcouchycouch » Sun Nov 10, 2013 9:51 pm

I've been trying to upconvert images from 16 colors to 256 colors and back.

For 16-to-256, I've tried variations of:

Code: Select all

convert -verbose backgroundforest2.bmp -type palette -colors 256 -depth 8 bmp3:backgroundforest2_256colors.bmp
But all I get is another 16 color bitmap. Is there a way to force it?


For 256-to-16, I've found something that works, but there's a snag.

Code: Select all

convert -verbose backgroundforest2_gg256colors.bmp -depth 4 -type palette -colors 16 bmp3:backgroundfores2_gg256to16.bmp
But the palette gets rearranged so that one of the colors used winds up to be the transparent color in the palette. Is there any way to tell Imagemagick to not reorder the palette?

Thanks!
djcc

UPDATE: Nevermind. Writing my own converters. :)

r57shell
Very interested
Posts: 478
Joined: Sun Dec 23, 2012 1:30 pm
Location: Russia
Contact:

Post by r57shell » Mon Nov 11, 2013 5:38 am

djcouchycouch wrote:I've been trying to upconvert images from 16 colors to 256 colors and back.
:shock:
Your image has 16 colors, where you will get MORE colors?
djcouchycouch wrote:Is there any way to tell Imagemagick to not reorder the palette?
Palette generated from image. ImageMagick doesn't know right order.
I'm not expert in ImageMagick.
djcouchycouch wrote:UPDATE: Nevermind. Writing my own converters. :)
Best way for me, it is first make image,
then reduce colors (by ImageMagick/GIMP/XiQuantizer/scolorq/Retro Graphics Toolkit or anything else),
then make palette in my Palette utility, and at last, insert in converter for MD.

I have alot of different converters for different cases for MD.
And all of them use input: png image and correspondend palette.
In output you will get .gfx (tiles) and .map (map) or bunch of other stuff like machine generated .asm files. (For sprites, I have utility that pack hundreds of sprites and generates 7 files: all tiles in once and other different data like sprites configs and tiles count...)
Image

djcouchycouch
Very interested
Posts: 683
Joined: Sat Feb 18, 2012 2:44 am

Post by djcouchycouch » Tue Nov 12, 2013 7:49 am

r57shell wrote:
djcouchycouch wrote:I've been trying to upconvert images from 16 colors to 256 colors and back.
:shock:
Your image has 16 colors, where you will get MORE colors?
It's not the colors I want, it's the format. genitile only accepts 8 bit images. so I want to take my source images (16 colors) and convert them to a tile set. to do that with genitile, I needed to convert the images. Imagemagick didn't help, so I wrote some small tools to up convert from 16 to 256 and back, keeping the palette identical.
djcouchycouch wrote:Is there any way to tell Imagemagick to not reorder the palette?
Palette generated from image. ImageMagick doesn't know right order.
I'm not expert in ImageMagick.
I had expected Imagemagick to take the source palette, but that's not the case.
djcouchycouch wrote:UPDATE: Nevermind. Writing my own converters. :)
Best way for me, it is first make image,
then reduce colors (by ImageMagick/GIMP/XiQuantizer/scolorq/Retro Graphics Toolkit or anything else),
then make palette in my Palette utility, and at last, insert in converter for MD.
I work the other way, drawing all my art assets in 16 colors from the start.

matteus
Very interested
Posts: 336
Joined: Mon Feb 04, 2008 1:41 pm

Post by matteus » Mon Feb 24, 2014 12:38 am

I'm doing animation via flash export to PNG but the colour palette index is always incorrect and I end up manually setting it in every image before running through the SGDK.

I'm using black in my graphics, so I want 36, 36, 36 (RGB) to be the default colour 0 (transparent) / background colour.

Is there a way I can do this using Imagemagick ?

Stef
Very interested
Posts: 3043
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef » Mon Feb 24, 2014 9:20 am

I'm now using Gimp to set the transparent color as you can re organize the colormap as you want. I believe that you can even use the real transparent color feature of the PNG format with SGDK (at least it worked on my sprite sample).

matteus
Very interested
Posts: 336
Joined: Mon Feb 04, 2008 1:41 pm

Post by matteus » Mon Feb 24, 2014 10:22 am

Stef wrote:I'm now using Gimp to set the transparent color as you can re organize the colormap as you want. I believe that you can even use the real transparent color feature of the PNG format with SGDK (at least it worked on my sprite sample).
I figure this maybe an issue with Fireworks MX not exporting the transparent colour feature properly (my tools are a little dated).

I batch export my images (which already use the MD colour palette and are already reduced to 15 colours) from Flash MX as 24-bit colour PNGs (using Flash's 8-bit PNG export doesn't work properly it over optimises the damn things!).

I then batch process the PNGs to 8-bit using Fireworks MX (which fails to use the transparent colour feature properly). I then manually rearrange the palette values in GIMP an image at a time.

I have 114 images so as you can probably tell this is just a tad time consuming! lol I'd like to be able to export from Flash then run a script to optimise the PNGs to 8bit with the default 0 palette position if possible. I see GIMP offers batch scripting but it looks incredibly daunting :D I may look to see if I can do this in Python...

r57shell
Very interested
Posts: 478
Joined: Sun Dec 23, 2012 1:30 pm
Location: Russia
Contact:

Post by r57shell » Mon Feb 24, 2014 1:12 pm

As far as I know, there is no way to set certain order of colors in ImageMagick.
Image

Post Reply