Page 1 of 1

Im4java in java

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

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

Re: Im4java in java

Posted: 2018-12-08T10:25:48-07:00
by snibgo
Im IM, "depth" means "pixels per channel per pixel". In some other programs, it means "total bits per pixel".

Re: Im4java in java

Posted: 2018-12-08T20:58:07-07:00
by neiyo7
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.

Re: Im4java in java

Posted: 2018-12-08T21:36:16-07:00
by snibgo
"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.