Edit image in Flash and Using Imagemagick at backend
Edit image in Flash and Using Imagemagick at backend
I want to create an application to allow user to edit images locally and send request to backend and using imageMagick to update actual image. I want to use Flash as local application, and once finished, send a http request to backend php, and then using commandline exec() to update images in server actually. Just like that of Flickr.
If this process is feasible, I having following questions:
1. My hosting provider only have ImageMagick 6.0.4, I know it is way to old, but can I still use that?
2. I can not find -recolor operation when using convert, is this only available to 6.3 or above? If so, any other alternatives in 6.0.4?
3. I used Flash
new ColorMatrixFilter([1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0.4,0]), but when I passed this matrix to imageMagick -recolor, the result is totally different. Does that mean in Flash colormatrixFilter and ImageMagick -recolor matrix, they have different meaning?
I don't have any php extension in my hosting provider, so I can only use commandline utilities.
If you can point me to some tutorial on how to realize the desired function, I will greatly appreciate it.
Thanks very much in advance.
If this process is feasible, I having following questions:
1. My hosting provider only have ImageMagick 6.0.4, I know it is way to old, but can I still use that?
2. I can not find -recolor operation when using convert, is this only available to 6.3 or above? If so, any other alternatives in 6.0.4?
3. I used Flash
new ColorMatrixFilter([1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0.4,0]), but when I passed this matrix to imageMagick -recolor, the result is totally different. Does that mean in Flash colormatrixFilter and ImageMagick -recolor matrix, they have different meaning?
I don't have any php extension in my hosting provider, so I can only use commandline utilities.
If you can point me to some tutorial on how to realize the desired function, I will greatly appreciate it.
Thanks very much in advance.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Edit image in Flash and Using Imagemagick at backend
the -recolor operator has been broken in some specific version of IM.
Try the following example, and see if you get a 'grey' image...
if it isn't grey, your IM -recolor is broken, upgrade ASAP.
Also there was a very recent fix for the handling of CMYK.
Try the following example, and see if you get a 'grey' image...
Code: Select all
convert rose: -recolor '.2 .5 .3 .2 .5 .3 .2 .5 .3' gray_recolor.png
Also there was a very recent fix for the handling of CMYK.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: Edit image in Flash and Using Imagemagick at backend
No my result is convert: unrecognized option `-recolor'.
I think 6.0.4 does not support -recolor
I contacted my hosting provider, they refused to upgrade to latest version.
I tried to install on my own account, I used ./configure -prefix=/home/xxx/ and then use make install, this is some errors;
/usr/bin/ld: skipping incompatible /usr/X11R6/lib/libX11.so when searching for - lX11
/usr/bin/ld: skipping incompatible /usr/X11R6/lib/libX11.a when searching for -l X11
/usr/bin/ld: cannot find -lX11
What does this mean? Does this mean for latest version, I need to install some library first? If so, are there any rpm package that install all the required libraries already?
Thanks
I think 6.0.4 does not support -recolor
I contacted my hosting provider, they refused to upgrade to latest version.
I tried to install on my own account, I used ./configure -prefix=/home/xxx/ and then use make install, this is some errors;
/usr/bin/ld: skipping incompatible /usr/X11R6/lib/libX11.so when searching for - lX11
/usr/bin/ld: skipping incompatible /usr/X11R6/lib/libX11.a when searching for -l X11
/usr/bin/ld: cannot find -lX11
What does this mean? Does this mean for latest version, I need to install some library first? If so, are there any rpm package that install all the required libraries already?
Thanks
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Edit image in Flash and Using Imagemagick at backend
Your IM is old in the extreme. At least three years old!!!
I hadn't even married yet when IM was at the version!
I hadn't even married yet when IM was at the version!
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: Edit image in Flash and Using Imagemagick at backend
I agree it is antique.
But my hosting provider refused to upgrade it! In order to install it in my own account in a shared hosting server with the old version also available, anything I need to follow?
I checked the posting for installing on shared hosting server here, not many. So can anyone please provide me with some instruction on how to install on shared server?
Do I need to install any libraries first?
Thanks
But my hosting provider refused to upgrade it! In order to install it in my own account in a shared hosting server with the old version also available, anything I need to follow?
I checked the posting for installing on shared hosting server here, not many. So can anyone please provide me with some instruction on how to install on shared server?
Do I need to install any libraries first?
Thanks
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Edit image in Flash and Using Imagemagick at backend
You have two choices, a "installed" and "uninstalled" version.
The difference is is the installed prefix is hardcoded as a system install, or it comes from the user defined $MAGICK_HOME environment variable.
For the later (using an enviornment varible build and install IM using the --disable-installed configuration option.
I myself prefer to do a system install using a --prefix configuration option to specify the top level install directory.
The important thing however is that BOTH your PATH environemtn varable and the LD_LIBRARY_PATH environemtn variables specifies to use YOUR installation BEFORE any other system installed version. that is try not to MIX the two versions.
I have raw notes on in
http://www.cit.gu.edu.au/~anthony/info/ ... gick.hints
The difference is is the installed prefix is hardcoded as a system install, or it comes from the user defined $MAGICK_HOME environment variable.
For the later (using an enviornment varible build and install IM using the --disable-installed configuration option.
I myself prefer to do a system install using a --prefix configuration option to specify the top level install directory.
The important thing however is that BOTH your PATH environemtn varable and the LD_LIBRARY_PATH environemtn variables specifies to use YOUR installation BEFORE any other system installed version. that is try not to MIX the two versions.
I have raw notes on in
http://www.cit.gu.edu.au/~anthony/info/ ... gick.hints
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: Edit image in Flash and Using Imagemagick at backend
Good day.
I faced the sameproblem recently. It seems that colormatrix in AS3(flash) and IM's recolor are differs in some way.
Just tried 'grey' paatern ('.2 .5 .3 .2 .5 .3 .2 .5 .3') and it worked well.
Now having hard time to determine what exactly is the difference.
Flash docu says that colormatrix computed by that formula:
while IM docu also doesnt say very much:
Secondly, flash matrix values (ay least 5th column) are not normalized between 0 and 1. They could sometimes be bigger.
I faced the sameproblem recently. It seems that colormatrix in AS3(flash) and IM's recolor are differs in some way.
Just tried 'grey' paatern ('.2 .5 .3 .2 .5 .3 .2 .5 .3') and it worked well.
Now having hard time to determine what exactly is the difference.
Flash docu says that colormatrix computed by that formula:
Code: Select all
redResult = (a[0] * srcR) + (a[1] * srcG) + (a[2] * srcB) + (a[3] * srcA) + a[4]
greenResult = (a[5] * srcR) + (a[6] * srcG) + (a[7] * srcB) + (a[8] * srcA) + a[9]
blueResult = (a[10] * srcR) + (a[11] * srcG) + (a[12] * srcB) + (a[13] * srcA) + a[14]
alphaResult = (a[15] * srcR) + (a[16] * srcG) + (a[17] * srcB) + (a[18] * srcA) + a[19]
First huge difference is size of matrix, flash use 4x5 matrix while IM want 5x5, maybe someone will help and explain something about that mysterious 5th row ?RecolorImage() translate, scale, shear, or rotate image colors. Although you can use variable sized matrices, typically you use a 5 x 5 for an RGBA image and a 6x6 for CMYKA. Populate the last row with normalized values to translate.
Secondly, flash matrix values (ay least 5th column) are not normalized between 0 and 1. They could sometimes be bigger.
Re: Edit image in Flash and Using Imagemagick at backend
The recolor matrix is set up like this in ImageMagick:
- dstR = a[0] * srcR + a[1] * srcG + a[2] * srcB + a[3] * srcA + a[20]
dstG = a[5] * srcR + a[6] * srcG + a[7] * srcB + a[8] * srcA + a[21]
dstB = a[10] * srcR + a[11] * srcG + a[12] * srcB + a[13] * srcA + a[22]
dstA = a[15] * srcR + a[16] * srcG + a[17] * srcB + a[18] * srcA + a[23]
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Edit image in Flash and Using Imagemagick at backend
See IM Examples...xtonic wrote: while IM docu also doesnt say very much:RecolorImage() translate, scale, shear, or rotate image colors. Although you can use variable sized matrices, typically you use a 5 x 5 for an RGBA image and a 6x6 for CMYKA. Populate the last row with normalized values to translate.
http://www.imagemagick.org/Usage/color/#recolor
yes it is just raw notes, but it basically explains the option.
The matrix can be 3x3 4x4 or 5x5 depending on if you are modifying a 3, 4, ot 5 channel image.
For example RGB or RGBA, or CMYKA respectively.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: Edit image in Flash and Using Imagemagick at backend
Any hint how to convert from flash matrix ? Maybe values should be normalized ?
Flash uses 4x5 matrix and RGBA, the 5th column is offset. I tried magick's formula
to convert the matrix, but it didnt worked, resulting image is still in acid colors.
magic's formula says that elements a[4], a[9], a[14], a[19] are not used in calculation
and therefore do not affect resulting image, but testing shows that they DO affect resulting image.
Thanks for reply.
Flash uses 4x5 matrix and RGBA, the 5th column is offset. I tried magick's formula
to convert the matrix, but it didnt worked, resulting image is still in acid colors.
magic's formula says that elements a[4], a[9], a[14], a[19] are not used in calculation
and therefore do not affect resulting image, but testing shows that they DO affect resulting image.
Thanks for reply.
Re: Edit image in Flash and Using Imagemagick at backend
Can you post a URL to an image, the Flash matrix you use and a URL to the results. We'll download it and see if we can reproduce the problem. If we get the acid colors we will look toward a patch to fix the problem.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Edit image in Flash and Using Imagemagick at backend
First you said 5 column. that would make it a 5x4 matrix (remember X or coumns) are always first!xtonic wrote:Any hint how to convert from flash matrix ? Maybe values should be normalized ?
Flash uses 4x5 matrix and RGBA, the 5th column is offset.
The ImageMagick re-color matrix (4x4) should then be the same as a transposed flash matrix
but without the last column (offset). It would treat that column as being a column of zeros.
Of course without someone experimenting to confirm this, it is speculation on my part, but that is what it sounds like. See the notes in the link I gave above. It explains how the matrix gets converted into color modifications.
Cristy DO NOT patch -recolor matrix. It is working correctly as defined!
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: Edit image in Flash and Using Imagemagick at backend
Hello again.
I'm testing it on following example: http://www.emanueleferonato.com/2009/04 ... ter-class/
Lets pick "Adding contrast" matrix, which is:
After converting it to magick matrix by magic's formula, i got this:
Now its time to apply it with perl script:
And voila! The black square 
I'm testing it on following example: http://www.emanueleferonato.com/2009/04 ... ter-class/
Lets pick "Adding contrast" matrix, which is:
Code: Select all
1.50 0.00 0.00 0.00 -40.00
0.00 1.50 0.00 0.00 -40.00
0.00 0.00 1.50 0.00 -40.00
0.00 0.00 0.00 1.00 0.00
Code: Select all
1.50 0.00 0.00 0.00 -40.00
0.00 1.50 0.00 0.00 -40.00
0.00 0.00 1.50 0.00 -40.00
0.00 0.00 0.00 1.00 0.00
-40.00 -40.00 -40.00 0.00 0.00
0.00 0.00 0.00 0.00 0.00
Code: Select all
#!/usr/local/bin/perl
use Image::Magick;
$image = Image::Magick->new;
$x = $image->Read('http://www.emanueleferonato.com/images/cats.jpg');
$image->Recolor([qw(
1.50 0.00 0.00 0.00 -40.00
0.00 1.50 0.00 0.00 -40.00
0.00 0.00 1.50 0.00 -40.00
0.00 0.00 0.00 1.00 0.00
-40.00 -40.00 -40.00 0.00 0.00
0.00 0.00 0.00 0.00 0.00)]);
$image->Write('result.jpg');

Re: Edit image in Flash and Using Imagemagick at backend
ImageMagick can be built at depths of 8, 16, or 32 so must use normalized values. Your command should look like this:
- convert cats.jpg -recolor \
" 1.50 0.00 0.00 0.00 \
0.00 1.50 0.00 0.00 \
0.00 0.00 1.50 0.00 \
-0.16 -0.16 -0.16 1.00" mycats.jpg
Re: Edit image in Flash and Using Imagemagick at backend
Sorry my abuse, but what is better solution ? Recompile with 32 bits ? Then normalization will not be required ?
Which range one should normalize ? 0..255 ? Im asking this annoying questions because result is now close, but still
do not match flash version. Thanks for your patience and good work.
Which range one should normalize ? 0..255 ? Im asking this annoying questions because result is now close, but still
do not match flash version. Thanks for your patience and good work.