8,7 → 8,6 |
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; |
41,7 → 40,8 |
protected static final int CACHED_NOT_MODIFIED = 1; |
protected static final int CACHED_WRITTEN = 2; |
|
protected Logger logger; |
private static final Logger logger = Logger.getLogger(Thumbnailer.class); |
|
protected ImageResizer resizer; |
protected int smallWidth = DEFAULT_SMALL_WIDTH; |
protected int smallHeight = DEFAULT_SMALL_HEIGHT; |
65,7 → 65,6 |
|
public Thumbnailer() |
{ |
this.logger = Logger.getLogger(this.getClass()); |
} |
|
public String getMime() |
140,16 → 139,16 |
in = new FileInputStream(origin); |
ii.setInput(in); |
|
if(!ii.check()) { |
if(ii.check()) { |
res[0] = ii.getWidth(); |
res[1] = ii.getHeight(); |
} |
else{ |
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(); |
} |
373,16 → 372,16 |
"unknown type of cached " + file.getCanonicalPath()); |
} |
|
if(origin != null && cache != null) { |
loadCacheInfo(file, origin, cache); |
} |
else { |
if(origin == null || cache == null) { |
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 |
553,10 → 552,12 |
return true; // image written |
} |
|
synchronized protected BufferedImage createThumbnail(File imageFile, |
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()); |
|
577,11 → 578,14 |
return resizer.resize(image, sizes[0], sizes[1]); |
} |
} |
} |
|
synchronized protected BufferedImage createThumbnailNative(File dir, File cacheFile, |
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()); |
588,7 → 592,7 |
|
dir.mkdirs(); |
|
// FIMXE: 1) make util path (and params?) configurable |
// FIXME: 1) make util path (and params?) configurable |
Process process = Runtime.getRuntime().exec(new String[] { |
"/usr/local/bin/convert", |
"-size", width + "x" + height, |
601,7 → 605,7 |
BufferedReader in = new BufferedReader(new InputStreamReader(process.getErrorStream())); |
String line; |
while((line = in.readLine()) != null) { |
System.out.println("EXEC: " + line); |
logger.info("EXEC: " + line); |
} |
|
try { |
616,10 → 620,13 |
|
return null; |
} |
} |
|
synchronized protected BufferedImage createDirThumbnail(File dir) |
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()) |
693,6 → 700,7 |
|
return dirThumbnail; |
} |
} |
|
protected Image loadImage(String fileName) |
{ |
795,8 → 803,9 |
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]; |
} |