mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-10 11:03:41 +02:00
OpenAI: scale images
This commit is contained in:
@@ -617,18 +617,22 @@ class ImageHelper {
|
||||
|
||||
static String getDataUri(File file, String type) throws IOException {
|
||||
try (InputStream is = new FileInputStream(file)) {
|
||||
byte[] bytes = Helper.readBytes(is);
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("data:");
|
||||
sb.append(type);
|
||||
sb.append(";base64,");
|
||||
sb.append(Base64.encodeToString(bytes, Base64.NO_WRAP));
|
||||
|
||||
return sb.toString();
|
||||
return getDataUri(is, type);
|
||||
}
|
||||
}
|
||||
|
||||
static String getDataUri(InputStream is, String type) throws IOException {
|
||||
byte[] bytes = Helper.readBytes(is);
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("data:");
|
||||
sb.append(type);
|
||||
sb.append(";base64,");
|
||||
sb.append(Base64.encodeToString(bytes, Base64.NO_WRAP));
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
static ByteArrayInputStream getDataUriStream(String source) {
|
||||
// "<img src=\"data:image/png;base64,iVBORw0KGgoAAA" +
|
||||
// "ANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4" +
|
||||
|
||||
Reference in New Issue
Block a user