Java change image size11/7/2023 ![]() ![]() You can contact Ajmal Abbasi for Consultancy, Technical Assistance and Technical Discussions. He has worked on a number of highly critical integration projects in various sectors by using his skills in TIBCO Flogo, TIBCO API Management (Mashery), TCI, Tibco Designer, TIBCO Business Studio, Adapters, TIBCO EMS, RV, Administrator, TIBCO BE, TIBCO ActiveSpaces etc.Ījmal Abbasi has experience with MuleSoft ESB as well.Ījmal Abbasi is also experienced in the area of API Management particularly with WSO2 API management platforms.Ījmal Abbasi is also experienced in developing solutions using Core Java and J2EE Technologies. He has extensive practical knowledge of TIBCO Business Works, TIBCO Cloud, TIBCO Flogo, TIBCO Mashery, TIBCO Spotfire, EMS and TIBCO ActiveSpaces. ImageIO.write(rBimg,ResizedFile.substring(ResizedFile.indexOf(“.”)+1),new FileOutputStream(ResizedFile)) Īfter compiling this code and running it you will get the new picture created in the specified location with the name resized_pic.java and the new image will have a width of 200 pixels and height will be based on the aspect ratio without losing picture quality.Ījmal Hussain Abbasi is Integration Consultant By Profession with 12+ years experience in Integration domain mainly with TIBCO products. Dispose the Graphics object, we no longer need it Graphics2D g=rBimg.createGraphics() // Draw the resizedImg from 0,0 with no ImageObserver Int scaled_height=resizedImg.getHeight(null) īufferedImage rBimg=new BufferedImage(width,scaled_height,bim.getType()) ![]() Image resizedImg=bim.getScaledInstance(width,-1,Image.SCALE_FAST) Also, the aspect ratio of the original image. Public static String resize(String sourceFile, String ResizedFile, int width) throws ExceptionīufferedImage bim=ImageIO.read(new FileInputStream(sourceFile)) Resizing an image means changing the dimensions of it, be it width alone, height alone or changing both of them. This method will resize the image to the specified width and will maintain aspect ratio for the height of the picture to maintain quality String result_message= resize(“C:\Pics\iqbal.png”,”C:\Pics\resized_pic.png”,200) Call static method to resize an image to 200 pixels width Public static void main(String args) throws Exception Below is the complete code for image resizing in Java When calling the resize method from the main method width value is specified as 200 so that resized image has a width of 200 pixels and height ratio is maintained. The source file being used for this example is iqbal.png which has a size 254×198. The method resizes the image and sends back the response (success message or exception message if there is any exception). ![]()
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |