21

I'm new in android, so i have a question to ask. I want to use the ImageMagick library to edit images in android but I don't wanna use the JMagick interface.

Has anybody import Imagemagick on Android before? If so, can you please give me some hints on how to do this?

Macarse
  • 91,829
  • 44
  • 175
  • 230
Greta
  • 211
  • 1
  • 2
  • 5

5 Answers5

23

I have ported it to android, and the code is in github.

James
  • 560
  • 4
  • 10
  • Thanks for your code. But I am having hard time to compile your code in my machine. Is it possible for you to explain how to work with your code? – Tae-Sung Shin Dec 18 '11 at 03:25
  • The latest github repo has included a rebuild script. You can have a look at it. Basically you modified the SDK variable in that script, and everything will work. – James Dec 29 '11 at 04:29
  • 1
    I downloaded the code, but I'm having trouble using it. First of all, I can't compile it, it's throwing some freetype missing errors, so I got that .so from an old commit. Now I'm having problems because there's a lot of java.awt references in Magick package, but I'm sure awt is unavaiable in Android – Paulo Cesar Mar 01 '12 at 00:38
  • 2
    Do you have android executable binaries? – thiagolr Mar 17 '14 at 12:08
  • How to convert frames to gif with it? – Anton Shkurenko Dec 07 '15 at 16:54
3

I guess nobody ported yet but you can do it yourself. You will basically need to get the sources and create an android.mk file.

There are several links that helped me out to build another lib:

Andres L
  • 683
  • 9
  • 20
Macarse
  • 91,829
  • 44
  • 175
  • 230
2

Just Ported it here, Still sketchy, But works for most.

Asiimwe
  • 2,199
  • 5
  • 24
  • 36
1

Use this one, it was compiled. it not awt; you just need compile test apk.Here is test example:

public class TesteNdkActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        try {
            ImageInfo i = new ImageInfo("/sdcard/DCIM/Camera/IMG_20120226_230240.jpg");
            MagickImage m = new MagickImage(i);

            int newHeight = (int) ((640/(float)m.getWidth()) * m.getHeight());
            m = m.scaleImage(640, newHeight);
            m = m.cropImage(new Rectangle((640-480)/2, 0, 480, 480));
            m = m.charcoalImage(0.5, 0.5);

            try {
                byte blob[] = m.imageToBlob(i);
                FileOutputStream fos = new FileOutputStream(new File("/sdcard/foto_teste.jpg"));
                fos.write(blob);
                fos.close();
            }
            catch (Exception e) {
                e.printStackTrace();
            }
        } 
        catch (MagickException e) {
            e.printStackTrace();
        }
    }
}

(text app will covert a picture to blob) I was successful, you will be successful. Enjoy it.

kangear
  • 2,493
  • 2
  • 31
  • 44
0

You may choose opencv library instead!

liangyao
  • 26
  • 1
  • Here's the problem: OpenCV is focused on computer vision, while ImageMagick is for more general image processing. It makes sense to combine both libraries, but, to me, using OpenCV instead of ImageMagick, if you have a task that only ImageMagick can do, does not make sense. – Gensoukyou1337 Jul 16 '18 at 03:13