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

17
LINES

< > BotCompany Repo | #1021826 // saveICO - save image as .ico (e.g. favicon.ico)

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

Uses 30K of libraries. Click here for Pure Java version (9420L/52K).

1  
// TODO: this is garbage as a favicon.ico
2  
// It needs all the different sizes (16x16, 32x32, 48x48)
3  
4  
lib 1400188 // image4j (https://sourceforge.net/projects/image4j/files/image4j-core/0.7.2/)
5  
6  
import net.sf.image4j.codec.ico.ICOEncoder;
7  
8  
static File saveICO(File f, BufferedImage img) ctex {
9  
  var img2 = cropToSquare(img);
10  
  L<Int> sizes = ll(16,32, 48);
11  
  ICOEncoder.write(map(sizes, size -> resizeImage(img2, size)), f);
12  
  ret f;
13  
}
14  
15  
static File saveICO(BufferedImage img, File f) {
16  
  ret saveICO(f, img);
17  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1021826
Snippet name: saveICO - save image as .ico (e.g. favicon.ico)
Eternal ID of this version: #1021826/6
Text MD5: d548bb9b78c5b6e3a364c77b5504018b
Transpilation MD5: eae970490948fecb42a19974015b57b4
Author: stefan
Category: javax / imaging
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-08-30 01:49:47
Source code size: 526 bytes / 17 lines
Pitched / IR pitched: No / No
Views / Downloads: 332 / 402
Version history: 5 change(s)
Referenced in: [show references]