-
-
Save madan712/3602189 to your computer and use it in GitHub Desktop.
/* ImageCropper.java */ | |
import java.awt.image.BufferedImage; | |
import java.io.File; | |
import java.io.IOException; | |
import javax.imageio.ImageIO; | |
public class ImageCropper { | |
public static void main(String[] args) { | |
try { | |
BufferedImage originalImgage = ImageIO.read(new File("C:/Test/pool.jpg")); | |
System.out.println("Original Image Dimension: "+originalImgage.getWidth()+"x"+originalImgage.getHeight()); | |
BufferedImage SubImgage = originalImgage.getSubimage(300, 150, 200, 200); | |
System.out.println("Cropped Image Dimension: "+SubImgage.getWidth()+"x"+SubImgage.getHeight()); | |
File outputfile = new File("C:/Test/croppedImage.jpg"); | |
ImageIO.write(SubImgage, "jpg", outputfile); | |
System.out.println("Image cropped successfully: "+outputfile.getPath()); | |
} catch (IOException e) { | |
e.printStackTrace(); | |
} | |
} | |
} |
nice thanks very much.
what ever may be the picture the output is same would you send me the reason?
Thanks very much this program what i need -- it allow u to position the part u want to crop then the size :)
Simple and functional. Exactly what I was looking for. Thanks so much!
work perfectly, Thank!!!
Really the perfect solution. Thank you for sharing!
I don't know, why the size after resize is much smaller than the original size?
e.g.
1.4mb down to 77 kb
Could you explain it to me? (bow)
Error: Could not create the Java Virtual Machine.
coming
Unrecognized option: --enable-preview
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
/home/webadmin/.cache/netbeans/12.2/executor-snippets/run.xml:111: The following error occurred while executing this line:
/home/webadmin/.cache/netbeans/12.2/executor-snippets/run.xml:94: Java returned: 1
BUILD FAILED (total time: 0 seconds)
Thanks very much this program what i need -- it allow u to position the part u want to crop then the size :)
is this working ??
Was looking around for image cropping in java and this is just what I needed