Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

18
LINES

< > BotCompany Repo | #1033523 // cropToLeftScreenInPlace

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (8890L/53K).

static File cropToRightScreenInPlace(File imageFile, int width, int height default Int.MAX_VALUE) {
  if (!isFile(imageFile)) null;
  
  loading "Crop image file" {
    BufferedImage img = loadImage2(imageFile);
    if (img.getWidth() <= width && img.getHeight() <= height) {
      print("Nothing to crop: " + imageFile);
      ret imageFile;
    }
    
    img = clipBufferedImage(img, 0, 0, width, height);
    File atticFile = appendToBaseFileName(imageFile, ".uncropped");
    renameFileVerbose(imageFile, atticFile);
    saveImageVerbose(imageFile, img);
    print("Image cropped to " + width + " pixels");
    ret imageFile;
  }
}

Author comment

Began life as a copy of #1032762

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1033523
Snippet name: cropToLeftScreenInPlace
Eternal ID of this version: #1033523/1
Text MD5: 9e6ed02d42e144d4e61262e3d3dadb3b
Transpilation MD5: cf747a737a858add8dba48c4614ebe2d
Author: stefan
Category: javax / io
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-10-31 02:38:47
Source code size: 653 bytes / 18 lines
Pitched / IR pitched: No / No
Views / Downloads: 70 / 96
Referenced in: [show references]