Ignore:
Timestamp:
Sep 1, 2010, 6:48:53 PM (14 years ago)
Author:
mlg
Message:

Bug correction :
bug:0001837 : there is now a default translation file (in english), so the application won't crash when a translation is not found
bug:0001833 : the accents are manage when creating a new category
bug:0001832 : on a right click on the categories list, the selection is now visible
bug:0001830 : there is no bug on refreshing the categories tree

Features :
feature:001828 : exif and iptc tags are kept after resizing an image
feature:001827 : pwg.images.addChunk is now fully used : images are split into chunks before being sent

Other features :

  • The user can manage his preferences :

-The web images size
-The chunks size

  • The user can save the login informations (url, login, password) /!\ in a plain text file !
File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/service/ImageService.java

    r6821 r6831  
    55import java.util.List;
    66
    7 import fr.mael.jiwigo.Main;
    87import fr.mael.jiwigo.dao.ImageDao;
    98import fr.mael.jiwigo.om.Image;
    109import fr.mael.jiwigo.transverse.enumeration.PreferencesEnum;
    1110import fr.mael.jiwigo.transverse.util.ImagesUtil;
    12 import fr.mael.jiwigo.transverse.util.MetadataExtractor;
     11import fr.mael.jiwigo.transverse.util.Outil;
    1312import fr.mael.jiwigo.transverse.util.preferences.PreferencesManagement;
    1413
     
    6766    }
    6867
     68    /**
     69     * Method called to send an image to the server.
     70     
     71     * @param filePath
     72     * @param idCategory
     73     * @return
     74     * @throws Exception
     75     */
    6976    public boolean creer(String filePath, Integer idCategory) throws Exception {
     77        //get the byte array of the original file, to keep metadata
     78        byte[] bytesFichierOriginal = Outil.getBytesFromFile(new File(filePath));
     79
     80        //size taken from the user's preferences
    7081        int widthOriginale = Integer
    7182                .valueOf(PreferencesManagement.getValue(PreferencesEnum.WIDTH_ORIGINALE.getLabel()));
    7283        int heightOriginale = Integer.valueOf(PreferencesManagement
    7384                .getValue(PreferencesEnum.HEIGHT_ORIGINAL.getLabel()));
     85        //resize the picture (or not)
    7486        boolean originaleRedimensionnee = ImagesUtil.scale(filePath, "originale.jpg", widthOriginale, heightOriginale);
     87        //create the thumbnail
    7588        ImagesUtil.scale(filePath, "thumb.jpg", 120, 90);
     89        //get the thumbnail
    7690        File thumbnail = new File(System.getProperty("java.io.tmpdir") + "/thumb.jpg");
    7791        File originale = null;
    7892        if (originaleRedimensionnee) {
    7993            originale = new File(System.getProperty("java.io.tmpdir") + "/originale.jpg");
     94            //if the original file has been resized, we put the metadata in the resized file
     95            //I use here a try catch because if the original file isn't a jpeg
     96            //the methode Outil.enrich will fail, but the procedure has to continue
     97            try {
     98                byte[] fichierEnrichi = Outil.enrich(bytesFichierOriginal, Outil.getBytesFromFile(new File(System
     99                        .getProperty("java.io.tmpdir")
     100                        + "/originale.jpg")));
     101                Outil.byteToFile(System.getProperty("java.io.tmpdir") + "/originale.jpg", fichierEnrichi);
     102            } catch (Exception e) {
     103            }
    80104        } else {
    81105            originale = new File(filePath);
    82         }
    83         MetadataExtractor medataExtractor = new MetadataExtractor(originale.getAbsolutePath());
    84         String auteur = medataExtractor.getAuteur();
    85         if (auteur == null) {
    86             auteur = Main.sessionManager.getLogin();
     106
    87107        }
    88108        Image image = new Image();
     
    90110        image.setThumbnail(thumbnail);
    91111        image.setOriginale(originale);
    92         image.setAuteur(auteur);
    93112        image.setIdCategory(idCategory);
     113        //now we call the dao to send the image to the webservice
    94114        return ImageDao.getInstance().creer(image);
    95115    }
    96116
     117    /**
     118     * Deletes the file extension
     119     * @param path
     120     * @return
     121     */
    97122    private String getImageName(String path) {
    98123        File fichier = new File(path);
Note: See TracChangeset for help on using the changeset viewer.