Package sk.iway.iwcm.common
Class ImageTools
java.lang.Object
sk.iway.iwcm.common.ImageTools
Manipulacia s obrazkami
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidconvertCmykToRgb(String filePath) Skonvertuje fotku do RGB ak je v CMYK, ak je konverzia povolena.static StringconvertImageFormat(IwcmFile imageFile, String targetFormat) Convert image to target format (jpg, png, gif).static intstatic intstatic intexecuteImageMagick(IwcmFile imageFile, List<String> args) Executes ImageMagick command.static intexecuteImageMagick(IwcmFile from, IwcmFile to, List<String> args) Executes ImageMagick command.static booleanChecks if ImageMagick convert command exists in configured directory.static intgetBufferedImageType(String fileName) Returns BufferedImage type based on file format.static Stringziska prikaz programu Identify (sucast Imagemagick)static Stringprikaz mogrify funguje rovnako ako convert ale ma ako parameter iba jednu cestu, prepisuje povodny vstupny subor http://www.imagemagick.org/www/mogrify.htmlstatic booleanReturns true if fileName is image file (ends with .jpg, png...)static booleanisResizableImage(String fileName) Returns true if fileName is image file and can be resized (ends with .jpg, png...static intresizeImage(String srcUrl, int width, int height) Resizne obrazok, vrati: 0-vsetko je OK 1-obrazok je uz teraz mensi 2-nepodarilo sa ulozit obrazok 3-nastala neznama chyba 4-obrazok je v nepodporovanom formatestatic intresizeImage(IwcmFile imageFile, int width, int height) static introtateImage(String srcUrl, double angle) static introtateImage(IwcmFile imageFile, double angle) static booleansupportsTransparency(String fileName) Returns true if the image format supports transparency (eg.static intwriteImage(BufferedImage image, String fileName, int imageQuality, IwcmFile outputFile) Writes BufferedImage to file in correct format based on file extension.
-
Method Details
-
supportsTransparency
Returns true if the image format supports transparency (eg. PNG, WEBP, GIF).- Parameters:
fileName- - file name with extension- Returns:
- true if file format supports transparency
-
getBufferedImageType
Returns BufferedImage type based on file format. For transparent images returns TYPE_INT_ARGB to preserve transparency, for others TYPE_INT_RGB.- Parameters:
fileName- - file name with extension- Returns:
- BufferedImage.TYPE_INT_ARGB or BufferedImage.TYPE_INT_RGB
-
writeImage
public static int writeImage(BufferedImage image, String fileName, int imageQuality, IwcmFile outputFile) Writes BufferedImage to file in correct format based on file extension. For transparent images preserves transparency. For JPG uses JPEG compression with 0.85 quality.- Parameters:
image- - BufferedImage to writefileName- - original file name to detect format (e.g. "photo.png")outputFile- - output IwcmFile to write to- Returns:
- 0 on success, 2 on error
-
isImage
Returns true if fileName is image file (ends with .jpg, png...)- Parameters:
fileName-- Returns:
-
isResizableImage
Returns true if fileName is image file and can be resized (ends with .jpg, png... but not .svg)- Parameters:
fileName-- Returns:
-
resizeImage
-
resizeImage
Resizne obrazok, vrati: 0-vsetko je OK 1-obrazok je uz teraz mensi 2-nepodarilo sa ulozit obrazok 3-nastala neznama chyba 4-obrazok je v nepodporovanom formate- Parameters:
srcUrl- - url adresa obrazkuwidth- - sirkaheight- - vyska- Returns:
-
cropImage
-
cropImage
-
rotateImage
-
executeImageMagick
Executes ImageMagick command. Handles IwcmFSDB storage, if image is stored in DB, it is first written to disk, then processed and finally written back to DB.- Parameters:
imageFile-args- - list of arguments, replaces from and to placeholders with real file paths, if they are present in args- Returns:
-
executeImageMagick
Executes ImageMagick command. Handles IwcmFSDB storage, if image is stored in DB, it is first written to disk, then processed and finally written back to DB.- Parameters:
from-to-args- - list of arguments, replaces from and to placeholders with real file paths, if they are present in args- Returns:
-
existsImageMagickConvertCommand
public static boolean existsImageMagickConvertCommand()Checks if ImageMagick convert command exists in configured directory.- Returns:
-
rotateImage
-
convertCmykToRgb
Skonvertuje fotku do RGB ak je v CMYK, ak je konverzia povolena.- Parameters:
filePath-
-
getIdentifyRuntimeFile
ziska prikaz programu Identify (sucast Imagemagick)- Returns:
-
getMogrifyRuntimeFile
prikaz mogrify funguje rovnako ako convert ale ma ako parameter iba jednu cestu, prepisuje povodny vstupny subor http://www.imagemagick.org/www/mogrify.html- Returns:
-
convertImageFormat
Convert image to target format (jpg, png, gif). If image is already in target format, no conversion is done and null is returned.- Parameters:
imageFile-targetFormat-- Returns:
- - new file name (without path) if conversion was done, null otherwise
-