image --load now store the file as is
[jvcard.git] / src / be / nikiroo / jvcard / launcher / Main.java
index eeeae4153a57eada0b58e04da065ea2d119101bc..65fbf9c635f51d4a097ca16604680faabe63c3eb 100644 (file)
@@ -319,8 +319,15 @@ public class Main {
                                                if (f.exists()) {
                                                        System.out.println("Loading " + f);
                                                        try {
-                                                               String b64 = StringUtils.fromImage(ImageIO
-                                                                               .read(f));
+                                                               String type = "jpeg";
+                                                               int dotIndex = filename.indexOf('.');
+                                                               if (dotIndex >= 0
+                                                                               && (dotIndex + 1) < filename.length()) {
+                                                                       type = filename.substring(dotIndex + 1)
+                                                                                       .toLowerCase();
+                                                               }
+
+                                                               String b64 = StringUtils.fromImage(f);
 
                                                                // remove previous photos:
                                                                for (Data photo = contact
@@ -332,7 +339,7 @@ public class Main {
 
                                                                List<TypeInfo> types = new LinkedList<TypeInfo>();
                                                                types.add(new TypeInfo("ENCODING", "b"));
-                                                               types.add(new TypeInfo("TYPE", "jpeg"));
+                                                               types.add(new TypeInfo("TYPE", type));
                                                                Data photo = new Data(types, "PHOTO", b64, null);
                                                                contact.add(photo);
                                                        } catch (IOException e) {