All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.leopard.data.dfs.service.image.ThumbnailUtil Maven / Gradle / Ivy

Go to download

分布式文件系统实现,目前只是做了基于GridFS的实现,可以在本机文件系统进行缓存。

There is a newer version: 0.9.12
Show newest version
package io.leopard.data.dfs.service.image;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class ThumbnailUtil {
	private static Pattern p = Pattern.compile("_([0-9]+x[0-9]+)\\.jpg$");

	public static ImageFileInfo parse(String filename) {
		// ImageFileParser
		Matcher m = p.matcher(filename);
		StringBuffer sb = new StringBuffer();
		if (!m.find()) {
			return null;
		}
		String size = m.group(1);
		m.appendReplacement(sb, ".jpg");
		m.appendTail(sb);

		String originalName = sb.toString();

		ImageFileInfo imageFileInfo = new ImageFileInfo();
		imageFileInfo.setOriginalName(originalName);
		imageFileInfo.setSize(size);
		return imageFileInfo;
	}

	public static boolean isMatcher(String filename) {
		Matcher m = p.matcher(filename);
		return m.find();
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy