|
24 | 24 |
|
25 | 25 | import app.photofox.vipsffm.VBlob; |
26 | 26 | import app.photofox.vipsffm.VImage; |
27 | | -import app.photofox.vipsffm.VSource; |
28 | 27 | import app.photofox.vipsffm.VipsOption; |
29 | 28 | import app.photofox.vipsffm.enums.VipsAccess; |
30 | 29 | import app.photofox.vipsffm.enums.VipsBandFormat; |
@@ -213,37 +212,8 @@ private static VImage bandReorder(Arena arena, VImage vimg, int... order) { |
213 | 212 |
|
214 | 213 | /** Loads an image from an InputStream, utilizing native loaders and ImageMagick fallback. */ |
215 | 214 | public static VImage loadAnyImage(Arena arena, InputStream inputStream) throws IOException { |
216 | | - try { |
217 | | - VSource source = VSource.newFromInputStream(arena, inputStream); |
218 | | - try { |
219 | | - // Try high-fidelity loaders with sequential access |
220 | | - return VImage.newFromSource(arena, source, "access=sequential,n=-1,fail=true"); |
221 | | - } catch (Exception e) { |
222 | | - try { |
223 | | - // Retry without 'n' parameter if the format doesn't support it (e.g. JXL, PNG, |
224 | | - // JPG) |
225 | | - return VImage.newFromSource(arena, source, "access=sequential,fail=true"); |
226 | | - } catch (Exception ex) { |
227 | | - log.debug( |
228 | | - "Standard native loader failed, trying ImageMagick fallback: {}", |
229 | | - ex.getMessage()); |
230 | | - try { |
231 | | - return VImage.magickloadSource(arena, source, VipsOption.Int("n", -1)); |
232 | | - } catch (Exception ex2) { |
233 | | - try { |
234 | | - return VImage.magickloadSource(arena, source); |
235 | | - } catch (Exception ex3) { |
236 | | - throw ex3; |
237 | | - } |
238 | | - } |
239 | | - } |
240 | | - } |
241 | | - } catch (Exception ex) { |
242 | | - log.error("Failed to load image with any available native loader", ex); |
243 | | - throw new IOException( |
244 | | - "Failed to load image with any available native loader: " + ex.getMessage(), |
245 | | - ex); |
246 | | - } |
| 215 | + byte[] bytes = inputStream.readAllBytes(); |
| 216 | + return loadAnyImage(arena, bytes); |
247 | 217 | } |
248 | 218 |
|
249 | 219 | /** Loads an image from bytes, utilizing native loaders and ImageMagick fallback. */ |
|
0 commit comments