Tags down


How do I crop an image in Java?

By : user3851948
Date : October 15 2020, 11:12 AM
will help you The solution I found most useful for cropping a buffered image uses the getSubImage(x,y,w,h);
My cropping routine ended up looking like this:
code :

Share : facebook icon twitter icon

How can I crop an image with negative crop-boundaries in Java?

By : tshtrifork
Date : March 29 2020, 07:55 AM
hop of those help? You don't need a library for this task.
You can create the new image that is resulted this way:
code :
BufferedImage newImage = new BufferedImage(width, height, imageType);
BufferedImage tempImage = oldImage.getSubimage(0, y, otherWidth, height);
Graphics2D g2 = newImage.createGraphics();
g2.drawImage(tempImage, x, 0, otherWidth, height, null);

How can I capture image and after crop the captured image and replace it with crop image?

By : Peter
Date : March 29 2020, 07:55 AM
hope this fix your issue It seems dublicate but it is not please look my question. , Try this, onActivityResult you will Returned data
code :
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    // TODO Auto-generated method stub
    super.onActivityResult(requestCode, resultCode, data);
    switch (requestCode) {

    case Utils.CROP_IMAGE:
        if (resultCode == RESULT_OK) {
            // Create an instance of bundle and get the returned data
            try {
                Uri outputFileUri = data.getData();
                             String path = getRealPathFromURI(outputFileUri)

            } catch (Exception e) {
                // TODO: handle exception

 public String getRealPathFromURI(Uri contentUri) 
 String[] proj = { MediaStore.Audio.Media.DATA };
 Cursor cursor = managedQuery(contentUri, proj, null, null, null);
 int column_index = cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.DATA);
 return cursor.getString(column_index);

AEM 6.0 Image crop tools (using Free Crop / Ratio Crop) not functioning properly but working in CQ 5

By : user3698107
Date : March 29 2020, 07:55 AM
Hope this helps Check image's field xtype. In old versions it was smartimge, now you need to use html5smartimage.
code :
<items jcr:primaryType="cq:WidgetCollection">

How to crop image in java?

By : Tomasz
Date : March 29 2020, 07:55 AM
seems to work fine
I want to crop image as above image (red line) but my code is seem incorrect.
code :
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;

public class Test {

    public static void main(String[] args) throws IOException {
        BufferedImage crop = new Test().crop(0.8509);
        System.out.println(crop.getWidth() + "x" + crop.getHeight());
        ImageIO.write(crop, "jpg", new File("Square.jpg"));

    public BufferedImage crop(double amount) throws IOException {
        BufferedImage originalImage = ImageIO.read(Test.class.getResource("Cat.jpg"));
        int height = originalImage.getHeight();
        int width = originalImage.getWidth();

        int targetWidth = (int)(width * amount);
        int targetHeight = (int)(height * amount);
        // Coordinates of the image's middle
        int xc = (width - targetWidth) / 2;
        int yc = (height - targetHeight) / 2;

        // Crop
        BufferedImage croppedImage = originalImage.getSubimage(
                        targetWidth, // widht
                        targetHeight // height
        return croppedImage;


How can i crop image using the HTML5 canvas and JavaScript in order to crop an image offline?

By : Roon Err
Date : March 29 2020, 07:55 AM
this will help If the image originated on the local domain, then you can easily crop it with html canvas.
But, if the image originated from another domain, you will run into CORS security errors: http://code.google.com/p/html5security/wiki/CrossOriginRequestSecurity
Related Posts Related Posts :
  • GWT DatePicker Locale
  • How would you design a twitter like message system, how to design the messaging system?
  • Is there a robust java.util.logging handler implementation of syslog?
  • Aligning messageformat on printing a JTable
  • SXXP0003: Error reported by XML parser: Content is not allowed in prolog
  • ehcache LRU evicting recently used entries
  • java cosine similarity problem
  • Efficient way to implement a client multiple file upload service
  • Regarding Object Comparison
  • How to embed IE in Swing application?
  • Using javax.tools.ToolProvider from a custom classloader?
  • What is the difference between i++ & ++i in a for loop?
  • Match a java main class with regexp
  • Confluence Persistence
  • Is there a way for a SecurityManager in java to selectively grant ReflectPermission("suppressAccessChecks")?
  • Using the camera activity in Android
  • Is communication in java rmi secure?
  • Java - how to make "runnable" JTable?
  • How can I write a Java program to draw a box, an oval, and an arrow?
  • What is the difference between ServletRequest's getRemoteHost() and getServerName()
  • java sparse matrix problem
  • ClassCastException when using HQL
  • how to generate a csv file through java code
  • Netbeans + tomcat on Ubuntu
  • How to connect to a remote MySQL database with Java?
  • System Event Handling using Java
  • How to change Ant script with EMMA code-coverage so it can find runtime coverage data?
  • Java bytecode iconst_0 iadd sequence
  • get the size of a list in a property
  • I want to convert a resultset to a string. I have tried everything but it always gives no data found. Please provide som
  • How can i sort java JTable with an empty Row and force the Empty row always be last?
  • How can I mount network drive in Mac OS X on Java?
  • XStream: How do I map xml mixed attributes and elements to POJOs?
  • begin with java voip
  • java: Preferences API vs. Apache Commons Configuration
  • Howto distinguish Application Quit from System Shutdown
  • How to go about with real GUI development with Java Swing and MVC
  • VB support in Java 6?
  • How to use jar files without package information?
  • how to inherit Constructor from super class to sub class
  • Multidimensional arrays in Java extends which class?
  • Connect to ibm mq with jms . Specify the channel and queue manager
  • Accessing the implicit objects from a JSP EL function
  • Find current heap size with jmap
  • Why doesn't Java have compound assignment versions of the conditional-and and conditional-or operators? (&&=, ||
  • What is the best way to manage configuration data
  • commons fileUpload: specifying an upload directory within Webapplication context
  • ModelAttributes not accessible on jsp
  • Session management between thick client and server?
  • Oracle JDBC intermittent Connection Issue
  • No mapping for LONGVARCHAR in Hibernate 3.2
  • A Packet Blocker Software
  • Anyone using Django in the "Enterprise"
  • Memory leak during repeated lucene query searches?
  • First steps developing in java applet. Directions
  • java efficient de-duplication
  • Converting sequential Java to concurrent java code
  • Java variable number or arguments for a method
  • when developing locally, does it make a difference if the context is '/' or '/appname/'?
  • Problem using JUnit4TestAdapter from eclipse plugin context
  • shadow
    Privacy Policy - Terms - Contact Us © bighow.org