Skip to content

Commit

Permalink
Added a jpegQuality field to the ImageMagick settings.
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre-Luc Paour committed Jul 19, 2003
1 parent 4c7002f commit d050371
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 19 deletions.
36 changes: 17 additions & 19 deletions com/gallery/GalleryRemote/util/ImageUtils.java
Expand Up @@ -52,7 +52,8 @@ public class ImageUtils {
static boolean useJpegtran = false;
static String jpegtranPath = null;
static File tmpDir = null;

static int jpegQuality = 75;

public static final int THUMB = 0;
public static final int PREVIEW = 1;
public static final int UPLOAD = 2;
Expand Down Expand Up @@ -83,26 +84,19 @@ public static ImageIcon load( String filename, Dimension d, int usage ) {
if (useIM) {
try {
StringBuffer cmdline = new StringBuffer(imPath);
cmdline.append(" -size ");

cmdline.append(d.width);
cmdline.append("x");
cmdline.append(d.height);


cmdline.append(" -size ").append(d.width).append("x").append(d.height);

if (filterName[usage] != null && filterName[usage].length() > 0) {
cmdline.append(" -filter ");
cmdline.append(filterName[usage]);
cmdline.append(" -filter ").append(filterName[usage]);
}

cmdline.append(" \"");
cmdline.append(filename);

cmdline.append("\" -resize ");
cmdline.append(d.width);
cmdline.append("x");
cmdline.append(d.height);
cmdline.append(" \"").append(filename).append("\"");

cmdline.append(" -resize \"").append(d.width).append("x").append(d.height).append("\" ");

cmdline.append(" +profile \"*\" ");

File temp = File.createTempFile("thumb", "." + format[usage], tmpDir);
toDelete.add(temp);

Expand Down Expand Up @@ -172,6 +166,8 @@ public static File resize( String filename, Dimension d ) {

//cmdline.append("-gravity SouthEast -draw \"image Over 200,200 0,0 G:\\Projects\\Dev\\gallery_remote10\\2ni.png\" ");

cmdline.append(" -quality ").append(jpegQuality);

r = File.createTempFile("res"
, "." + GalleryFileFilter.getExtension(filename), tmpDir);
toDelete.add(r);
Expand Down Expand Up @@ -346,6 +342,8 @@ public static ImageIcon rotateImageIcon(ImageIcon thumb, int angle, boolean flip
format[THUMB] = p.getProperty("imThumbnailResizeFormat", "gif");
format[PREVIEW] = p.getProperty("imPreviewResizeFormat", "jpg");
format[UPLOAD] = null;

jpegQuality = p.getIntProperty("jpegQuality", jpegQuality);
}
} catch (Exception e) {
Log.logException(Log.CRITICAL, MODULE, e);
Expand Down Expand Up @@ -402,12 +400,12 @@ public static Dimension getSizeKeepRatio(Dimension source, Dimension target)
if (targetRatio > sourceRatio)
{
result.height = target.height;
result.width = (int) source.width * target.height / source.height;
result.width = source.width * target.height / source.height;
}
else
{
result.width = target.width;
result.height = (int) source.height * target.width / source.width;
result.height = source.height * target.width / source.width;
}

return result;
Expand Down
3 changes: 3 additions & 0 deletions imagemagick/linux/im.properties
Expand Up @@ -39,3 +39,6 @@ imThumbnailResizeFormat=gif

# filter used for resize of preview
imPreviewResizeFormat=jpg

# jpeg quality
jpegQuality=80
3 changes: 3 additions & 0 deletions imagemagick/macos/im.properties
Expand Up @@ -39,3 +39,6 @@ imThumbnailResizeFormat=gif

# filter used for resize of preview
imPreviewResizeFormat=jpg

# jpeg quality
jpegQuality=80
3 changes: 3 additions & 0 deletions imagemagick/solaris/im.properties
Expand Up @@ -39,3 +39,6 @@ imThumbnailResizeFormat=gif

# filter used for resize of preview
imPreviewResizeFormat=jpg

# jpeg quality
jpegQuality=80
3 changes: 3 additions & 0 deletions imagemagick/win32/im.properties
Expand Up @@ -39,3 +39,6 @@ imThumbnailResizeFormat=gif

# filter used for resize of preview
imPreviewResizeFormat=jpg

# jpeg quality
jpegQuality=80

0 comments on commit d050371

Please sign in to comment.