8,6 → 8,7 |
import java.io.FileFilter; |
import java.io.IOException; |
import java.io.FileInputStream; |
import java.io.FileOutputStream; |
import java.io.OutputStream; |
import java.io.BufferedReader; |
import java.io.InputStreamReader; |
40,8 → 41,7 |
protected static final int CACHED_NOT_MODIFIED = 1; |
protected static final int CACHED_WRITTEN = 2; |
|
private static final Logger logger = Logger.getLogger(Thumbnailer.class); |
|
protected Logger logger; |
protected ImageResizer resizer; |
protected int smallWidth = DEFAULT_SMALL_WIDTH; |
protected int smallHeight = DEFAULT_SMALL_HEIGHT; |
65,6 → 65,7 |
|
public Thumbnailer() |
{ |
this.logger = Logger.getLogger(this.getClass()); |
} |
|
public String getMime() |
139,16 → 140,16 |
in = new FileInputStream(origin); |
ii.setInput(in); |
|
if(ii.check()) { |
res[0] = ii.getWidth(); |
res[1] = ii.getHeight(); |
} |
else{ |
if(!ii.check()) { |
logger.warn("not supported format of " + origin.getCanonicalPath()); |
res[0] = 0; |
res[1] = 0; |
} |
else{ |
res[0] = ii.getWidth(); |
res[1] = ii.getHeight(); |
} |
} |
finally { |
if(in != null) in.close(); |
} |
372,16 → 373,16 |
"unknown type of cached " + file.getCanonicalPath()); |
} |
|
if(origin == null || cache == null) { |
if(origin != null && cache != null) { |
loadCacheInfo(file, origin, cache); |
} |
else { |
file.delete(); |
|
if(logger.isDebugEnabled()) |
logger.debug("deleted (unknown origin)"); |
} |
else { |
loadCacheInfo(file, origin, cache); |
} |
} |
|
protected void loadCacheInfo(File file, File origin, Map cache) |
throws IOException |
552,12 → 553,10 |
return true; // image written |
} |
|
protected BufferedImage createThumbnail(File imageFile, |
synchronized protected BufferedImage createThumbnail(File imageFile, |
int width, int height) |
throws IOException |
{ |
// FIXME make several instances parallel if we have sevelar processors |
synchronized(this) { |
if(logger.isDebugEnabled()) |
logger.debug("create thumbnail " + imageFile.getCanonicalPath()); |
|
578,14 → 577,11 |
return resizer.resize(image, sizes[0], sizes[1]); |
} |
} |
} |
|
protected BufferedImage createThumbnailNative(File dir, File cacheFile, |
synchronized protected BufferedImage createThumbnailNative(File dir, File cacheFile, |
File imageFile, int width, int height) |
throws IOException |
{ |
// FIXME make several instances parallel if we have sevelar processors |
synchronized(this) { |
if(logger.isDebugEnabled()) |
logger.debug("create thumbnail2 " + imageFile.getCanonicalPath() + " to " |
+ cacheFile.getCanonicalPath()); |
592,7 → 588,7 |
|
dir.mkdirs(); |
|
// FIXME: 1) make util path (and params?) configurable |
// FIMXE: 1) make util path (and params?) configurable |
Process process = Runtime.getRuntime().exec(new String[] { |
"/usr/local/bin/convert", |
"-size", width + "x" + height, |
605,7 → 601,7 |
BufferedReader in = new BufferedReader(new InputStreamReader(process.getErrorStream())); |
String line; |
while((line = in.readLine()) != null) { |
logger.info("EXEC: " + line); |
System.out.println("EXEC: " + line); |
} |
|
try { |
620,13 → 616,10 |
|
return null; |
} |
} |
|
protected BufferedImage createDirThumbnail(File dir) |
synchronized protected BufferedImage createDirThumbnail(File dir) |
throws IOException |
{ |
// FIXME make several instances parallel if we have sevelar processors |
synchronized(this) { |
long timeStart = System.currentTimeMillis(); |
|
if(logger.isDebugEnabled()) |
700,7 → 693,6 |
|
return dirThumbnail; |
} |
} |
|
protected Image loadImage(String fileName) |
{ |
803,9 → 795,8 |
Arrays.sort(children, fileNameComparatorRev); |
|
for(int i = 0; i < children.length && pos < count; i++) { |
if(children[i].isDirectory()) { |
//pos = getFirstFiles(children[i], count, files, pos); |
} |
if(children[i].isDirectory()) |
; //pos = getFirstFiles(children[i], count, files, pos); |
else { |
files[pos++] = children[i]; |
} |