Changing The Size Of An Image

Changing The Size Of An Image

Changing The Size Of An Image.
First off, I would just like to say that i�m a French Canadian student so my English is not very good, and that I�m not an expert in JMagick so this might not be the best way to do it. If there is a better way your welcome to send it to me and I will make correction to this document.
One very useful feature of ImageMagick is to be able to resize images. This function is great for creating thumbnails or for making full screen images. It might seem a little complex at first but manipulating images with JMagick is a very simple and powerful thing.
Step 1: Reading The Picture Files

      ImageInfo info = new ImageInfo();
      MagickImage image = new MagickImage( new ImageInfo( "testpic.jpg" ) );

For more information on reading pictures look at the previous tutorials.
Step 2: Resizing

      MagickImage bigger = image.scaleImage(1200, 900);

As you can see this is pretty straightforward, you use your already existing instance of

 MagickImage that we named image use the scaleImage method with the desired width(1200)

and height(900). The method returns a MagickImage object witch is the new resized image.
Step 3: Writing the new file

      bigger.setFileName("bigger.jpg");
      bigger.writeImage(info);

All that is left to do is to create a new file in this case its called bigger.jpg but we could have also overwritten testpic.jpg

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值