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

18
LINES

< > BotCompany Repo | #1015317 // jpegify - convert image file to JPEG

JavaX fragment (include)

1  
static File jpegify(File imageFile, bool makeBackup default true) {
2  
  if (isJPEGFile(imageFile)) ret imageFile;
3  
  loading "JPEGify" {
4  
    BufferedImage img = loadImage2(imageFile);
5  
    File destFile = replaceExtension(imageFile, ".jpg");
6  
    File atticFile = makeBackup ?
7  
      newFile(javaxDataDir("JPEGified original pictures"), imageFile.getName()) : null;
8  
    if (makeBackup)
9  
      atticFile = makeFileNameUnique(atticFile);
10  
    saveJPGVerbose(destFile, img);
11  
    if (makeBackup)
12  
      moveFileVerbose(imageFile, atticFile);
13  
    else
14  
      deleteFile(imageFile);
15  
    print("Conversion done.");
16  
    ret destFile;
17  
  }
18  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gjtlkbvenryc, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1015317
Snippet name: jpegify - convert image file to JPEG
Eternal ID of this version: #1015317/10
Text MD5: fd6fddf2ec9fe16f5816b7630348de1c
Author: stefan
Category: javax / io
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2024-10-06 21:42:38
Source code size: 638 bytes / 18 lines
Pitched / IR pitched: No / No
Views / Downloads: 709 / 685
Version history: 9 change(s)
Referenced in: [show references]