Libraryless. Click here for Pure Java version (7601L/45K).
1 | static File cropToLeftScreenInPlace(File imageFile) { |
2 | ret cropToLeftScreenInPlace(imageFile, screenWidth(), screenHeight()); |
3 | } |
4 | |
5 | static File cropToLeftScreenInPlace(File imageFile, int width, int height default Int.MAX_VALUE) { |
6 | if (!isFile(imageFile)) null; |
7 | |
8 | loading "Crop image file" { |
9 | BufferedImage img = loadImage2(imageFile); |
10 | if (img.getWidth() <= width && img.getHeight() <= height) { |
11 | print("Nothing to crop: " + imageFile); |
12 | ret imageFile; |
13 | } |
14 | |
15 | img = clipBufferedImage(img, 0, 0, width, height); |
16 | File atticFile = appendToBaseFileName(imageFile, ".uncropped"); |
17 | renameFileVerbose(imageFile, atticFile); |
18 | saveImageVerbose(imageFile, img); |
19 | print("Image cropped to " + width + " pixels"); |
20 | ret imageFile; |
21 | } |
22 | } |
Began life as a copy of #1015317
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj, pyentgdyhuwx
No comments. add comment
Snippet ID: | #1032043 |
Snippet name: | cropToLeftScreenInPlace |
Eternal ID of this version: | #1032043/4 |
Text MD5: | 37c215093ce4e7e658077f388b7ed5f4 |
Transpilation MD5: | d904407c34bf6f530b237421b05b9c59 |
Author: | stefan |
Category: | javax / io |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-08-30 03:41:44 |
Source code size: | 786 bytes / 22 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 141 / 261 |
Version history: | 3 change(s) |
Referenced in: | [show references] |