0.5.1 does not support UPPER and Mixed case
exentions. This is problematic as most digital cameras
store files in DOS FAT format which maps to uppercase
on most moden operating systems. Below is a patch to
ImageHandler.java to add support for UPPER and Mixed
case (I refactored the library for MyEclipse the paths are
a little different, but this should be easy to apply by
hand)
Index:
src/net/sourceforge/jimagetaglib/image/ImageHandler.jav
a
=========================================
==========================
RCS file: /home/cvs/jimagetaglib-
0.5.1/src/net/sourceforge/jimagetaglib/image/ImageHandl
er.java,v
retrieving revision 1.1
diff -u -r1.1 ImageHandler.java
---
src/net/sourceforge/jimagetaglib/image/ImageHandler.jav
a 4 Aug 2005 20:34:52 -0000 1.1
+++
src/net/sourceforge/jimagetaglib/image/ImageHandler.jav
a 4 Aug 2005 21:14:59 -0000
@@ -30,7 +30,7 @@
private Image inImage = null;
private String extensao = null;
private boolean
resizeIfImageIsSmallerThanSpecifiedSize =
Constants.DEFAULT_RESIZE_IF_IMAGE_IS_SMALLER
;
- static final private String[] validFileExt =
{ ".gif", ".jpeg", ".jpg" };
+ static final private String[] validFileExt =
{ ".gif", ".jpeg", ".jpg" }; // Must be lower case here
private BufferedImage theImage;
private Graphics2D g2d;
@@ -199,11 +199,17 @@
/**
* Verifies if image is valid for the system.
+ *
+ * Modified DHB, check to insure extensao
matches validFileExt ignoring case.
+ *
* @return
*/
private boolean isValidImage() {
// Aceita somente .gif, .jpg
ou .jpeg
- return (Arrays.binarySearch
(validFileExt, extensao) > -1);
+ for (int i=0; i < validFileExt.length; i++) {
+ if (extensao.equalsIgnoreCase
(validFileExt[i])) { return true; }
+ }
+ return false;
}
/**
@@ -214,7 +220,7 @@
if (extensao != null) {
if (extensao.trim
().equals(".gif"))
return "image/gif";
- else if ((extensao.trim
().equals(".jpg")) || (extensao.trim().equals(".jpeg")))
+ else if ((extensao.trim
().equalsIgnoreCase(".jpg")) || (extensao.trim
().equalsIgnoreCase(".jpeg")))
return "image/jpeg";
}
return null;
jimagetaglib-0.5.1-ignore_ext_case.patch