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

18
LINES

< > BotCompany Repo | #1032762 // cropToRightScreenInPlace

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

Libraryless. Click here for Pure Java version (8255L/50K).

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, img.getWidth()-width, 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 #1032043

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1032762
Snippet name: cropToRightScreenInPlace
Eternal ID of this version: #1032762/1
Text MD5: fc642e697d10da570456f0e7b6b5afba
Transpilation MD5: 4e9dde8ed2ba39d03e22f3cd2ea74be6
Author: stefan
Category: javax / io
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-10-04 17:07:32
Source code size: 672 bytes / 18 lines
Pitched / IR pitched: No / No
Views / Downloads: 86 / 158
Referenced in: [show references]