Im4java in java

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
neiyo7
Posts: 2
Joined: 2018-12-08T08:19:51-07:00
Authentication code: 1152

Im4java in java

Post by neiyo7 » 2018-12-08T08:26:43-07:00

Code: Select all

public static boolean zoomImage(String srcImagePath, String newImagePath, Integer width, Integer height, int qual)
	{
		try
		{
			IMOperation op = new IMOperation();
			op.thumbnail(width, height);
			op.gravity("center");
			op.background("white");
			op.depth(8);//No effect!!
			op.extent(width, height);
			op.quality((double) qual);
			op.addImage(srcImagePath);
			op.addImage(newImagePath);
			ImageCommand convert = getImageCommand(CommandType.convert);
			convert.run(op);
			System.out.println("OK");
		}
		catch (Exception e)
		{
			e.printStackTrace();
			return false;
		}
		return true;
	}

this line "op.depth(8);//No effect!!" It' not work!, the image always "depth:24 ", How can I change it? help me

snibgo
Posts: 10929
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Im4java in java

Post by snibgo » 2018-12-08T10:25:48-07:00

Im IM, "depth" means "pixels per channel per pixel". In some other programs, it means "total bits per pixel".
snibgo's IM pages: im.snibgo.com

neiyo7
Posts: 2
Joined: 2018-12-08T08:19:51-07:00
Authentication code: 1152

Re: Im4java in java

Post by neiyo7 » 2018-12-08T20:58:07-07:00

I know that, I want to change the depth 24 to 8 , reduce image size.
It's also a way to adjust the quality. I want to see if there are other ways to solve this problem.

snibgo
Posts: 10929
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Im4java in java

Post by snibgo » 2018-12-08T21:36:16-07:00

"depth(8)" will reduce the image to 8 bits/channel/pixel. Perhaps you want "-type Palette". Some other function will do that. Sorry, I don't know IM for Java.
snibgo's IM pages: im.snibgo.com

Post Reply