├── .gitignore ├── LICENSE ├── README.md ├── pom.xml └── src └── main ├── java └── enlarger │ ├── FixIcons.java │ ├── FixIconsProcessor.java │ └── ImageType.java └── resources └── log4j.properties /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /.settings 3 | /.classpath 4 | /.project 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Eclipse Public License - v 1.0 2 | 3 | THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC 4 | LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM 5 | CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. 6 | 7 | 1. DEFINITIONS 8 | 9 | "Contribution" means: 10 | 11 | a) in the case of the initial Contributor, the initial code and documentation 12 | distributed under this Agreement, and 13 | b) in the case of each subsequent Contributor: 14 | i) changes to the Program, and 15 | ii) additions to the Program; 16 | 17 | where such changes and/or additions to the Program originate from and are 18 | distributed by that particular Contributor. A Contribution 'originates' 19 | from a Contributor if it was added to the Program by such Contributor 20 | itself or anyone acting on such Contributor's behalf. Contributions do not 21 | include additions to the Program which: (i) are separate modules of 22 | software distributed in conjunction with the Program under their own 23 | license agreement, and (ii) are not derivative works of the Program. 24 | 25 | "Contributor" means any person or entity that distributes the Program. 26 | 27 | "Licensed Patents" mean patent claims licensable by a Contributor which are 28 | necessarily infringed by the use or sale of its Contribution alone or when 29 | combined with the Program. 30 | 31 | "Program" means the Contributions distributed in accordance with this 32 | Agreement. 33 | 34 | "Recipient" means anyone who receives the Program under this Agreement, 35 | including all Contributors. 36 | 37 | 2. GRANT OF RIGHTS 38 | a) Subject to the terms of this Agreement, each Contributor hereby grants 39 | Recipient a non-exclusive, worldwide, royalty-free copyright license to 40 | reproduce, prepare derivative works of, publicly display, publicly 41 | perform, distribute and sublicense the Contribution of such Contributor, 42 | if any, and such derivative works, in source code and object code form. 43 | b) Subject to the terms of this Agreement, each Contributor hereby grants 44 | Recipient a non-exclusive, worldwide, royalty-free patent license under 45 | Licensed Patents to make, use, sell, offer to sell, import and otherwise 46 | transfer the Contribution of such Contributor, if any, in source code and 47 | object code form. This patent license shall apply to the combination of 48 | the Contribution and the Program if, at the time the Contribution is 49 | added by the Contributor, such addition of the Contribution causes such 50 | combination to be covered by the Licensed Patents. The patent license 51 | shall not apply to any other combinations which include the Contribution. 52 | No hardware per se is licensed hereunder. 53 | c) Recipient understands that although each Contributor grants the licenses 54 | to its Contributions set forth herein, no assurances are provided by any 55 | Contributor that the Program does not infringe the patent or other 56 | intellectual property rights of any other entity. Each Contributor 57 | disclaims any liability to Recipient for claims brought by any other 58 | entity based on infringement of intellectual property rights or 59 | otherwise. As a condition to exercising the rights and licenses granted 60 | hereunder, each Recipient hereby assumes sole responsibility to secure 61 | any other intellectual property rights needed, if any. For example, if a 62 | third party patent license is required to allow Recipient to distribute 63 | the Program, it is Recipient's responsibility to acquire that license 64 | before distributing the Program. 65 | d) Each Contributor represents that to its knowledge it has sufficient 66 | copyright rights in its Contribution, if any, to grant the copyright 67 | license set forth in this Agreement. 68 | 69 | 3. REQUIREMENTS 70 | 71 | A Contributor may choose to distribute the Program in object code form under 72 | its own license agreement, provided that: 73 | 74 | a) it complies with the terms and conditions of this Agreement; and 75 | b) its license agreement: 76 | i) effectively disclaims on behalf of all Contributors all warranties 77 | and conditions, express and implied, including warranties or 78 | conditions of title and non-infringement, and implied warranties or 79 | conditions of merchantability and fitness for a particular purpose; 80 | ii) effectively excludes on behalf of all Contributors all liability for 81 | damages, including direct, indirect, special, incidental and 82 | consequential damages, such as lost profits; 83 | iii) states that any provisions which differ from this Agreement are 84 | offered by that Contributor alone and not by any other party; and 85 | iv) states that source code for the Program is available from such 86 | Contributor, and informs licensees how to obtain it in a reasonable 87 | manner on or through a medium customarily used for software exchange. 88 | 89 | When the Program is made available in source code form: 90 | 91 | a) it must be made available under this Agreement; and 92 | b) a copy of this Agreement must be included with each copy of the Program. 93 | Contributors may not remove or alter any copyright notices contained 94 | within the Program. 95 | 96 | Each Contributor must identify itself as the originator of its Contribution, 97 | if 98 | any, in a manner that reasonably allows subsequent Recipients to identify the 99 | originator of the Contribution. 100 | 101 | 4. COMMERCIAL DISTRIBUTION 102 | 103 | Commercial distributors of software may accept certain responsibilities with 104 | respect to end users, business partners and the like. While this license is 105 | intended to facilitate the commercial use of the Program, the Contributor who 106 | includes the Program in a commercial product offering should do so in a manner 107 | which does not create potential liability for other Contributors. Therefore, 108 | if a Contributor includes the Program in a commercial product offering, such 109 | Contributor ("Commercial Contributor") hereby agrees to defend and indemnify 110 | every other Contributor ("Indemnified Contributor") against any losses, 111 | damages and costs (collectively "Losses") arising from claims, lawsuits and 112 | other legal actions brought by a third party against the Indemnified 113 | Contributor to the extent caused by the acts or omissions of such Commercial 114 | Contributor in connection with its distribution of the Program in a commercial 115 | product offering. The obligations in this section do not apply to any claims 116 | or Losses relating to any actual or alleged intellectual property 117 | infringement. In order to qualify, an Indemnified Contributor must: 118 | a) promptly notify the Commercial Contributor in writing of such claim, and 119 | b) allow the Commercial Contributor to control, and cooperate with the 120 | Commercial Contributor in, the defense and any related settlement 121 | negotiations. The Indemnified Contributor may participate in any such claim at 122 | its own expense. 123 | 124 | For example, a Contributor might include the Program in a commercial product 125 | offering, Product X. That Contributor is then a Commercial Contributor. If 126 | that Commercial Contributor then makes performance claims, or offers 127 | warranties related to Product X, those performance claims and warranties are 128 | such Commercial Contributor's responsibility alone. Under this section, the 129 | Commercial Contributor would have to defend claims against the other 130 | Contributors related to those performance claims and warranties, and if a 131 | court requires any other Contributor to pay any damages as a result, the 132 | Commercial Contributor must pay those damages. 133 | 134 | 5. NO WARRANTY 135 | 136 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN 137 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR 138 | IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, 139 | NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each 140 | Recipient is solely responsible for determining the appropriateness of using 141 | and distributing the Program and assumes all risks associated with its 142 | exercise of rights under this Agreement , including but not limited to the 143 | risks and costs of program errors, compliance with applicable laws, damage to 144 | or loss of data, programs or equipment, and unavailability or interruption of 145 | operations. 146 | 147 | 6. DISCLAIMER OF LIABILITY 148 | 149 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY 150 | CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, 151 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION 152 | LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 153 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 154 | ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE 155 | EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY 156 | OF SUCH DAMAGES. 157 | 158 | 7. GENERAL 159 | 160 | If any provision of this Agreement is invalid or unenforceable under 161 | applicable law, it shall not affect the validity or enforceability of the 162 | remainder of the terms of this Agreement, and without further action by the 163 | parties hereto, such provision shall be reformed to the minimum extent 164 | necessary to make such provision valid and enforceable. 165 | 166 | If Recipient institutes patent litigation against any entity (including a 167 | cross-claim or counterclaim in a lawsuit) alleging that the Program itself 168 | (excluding combinations of the Program with other software or hardware) 169 | infringes such Recipient's patent(s), then such Recipient's rights granted 170 | under Section 2(b) shall terminate as of the date such litigation is filed. 171 | 172 | All Recipient's rights under this Agreement shall terminate if it fails to 173 | comply with any of the material terms or conditions of this Agreement and does 174 | not cure such failure in a reasonable period of time after becoming aware of 175 | such noncompliance. If all Recipient's rights under this Agreement terminate, 176 | Recipient agrees to cease use and distribution of the Program as soon as 177 | reasonably practicable. However, Recipient's obligations under this Agreement 178 | and any licenses granted by Recipient relating to the Program shall continue 179 | and survive. 180 | 181 | Everyone is permitted to copy and distribute copies of this Agreement, but in 182 | order to avoid inconsistency the Agreement is copyrighted and may only be 183 | modified in the following manner. The Agreement Steward reserves the right to 184 | publish new versions (including revisions) of this Agreement from time to 185 | time. No one other than the Agreement Steward has the right to modify this 186 | Agreement. The Eclipse Foundation is the initial Agreement Steward. The 187 | Eclipse Foundation may assign the responsibility to serve as the Agreement 188 | Steward to a suitable separate entity. Each new version of the Agreement will 189 | be given a distinguishing version number. The Program (including 190 | Contributions) may always be distributed subject to the version of the 191 | Agreement under which it was received. In addition, after a new version of the 192 | Agreement is published, Contributor may elect to distribute the Program 193 | (including its Contributions) under the new version. Except as expressly 194 | stated in Sections 2(a) and 2(b) above, Recipient receives no rights or 195 | licenses to the intellectual property of any Contributor under this Agreement, 196 | whether expressly, by implication, estoppel or otherwise. All rights in the 197 | Program not expressly granted under this Agreement are reserved. 198 | 199 | This Agreement is governed by the laws of the State of New York and the 200 | intellectual property laws of the United States of America. No party to this 201 | Agreement will bring a legal action under this Agreement more than one year 202 | after the cause of action arose. Each party waives its rights to a jury trial in 203 | any resulting litigation. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | eclipse-icon-enlarger 2 | ===================== 3 | 4 | Scales Eclipse icons (PNG and GIF) to double their size for QHD laptops. 5 | 6 | #### How To Build 7 | 8 | 1. Clone this repository localy 9 | 2. Run 'mvn clean package' 10 | 3. You eclipse-icon-enlarger.jar with all dependencies is ready! 11 | 12 | #### How To Run 13 | 14 | java -jar eclipse-icon-enlarger.jar -b c:\eclipse -o c:\Temp\eclipse_qhd 15 | -b,--baseDir This is the base directory where we'll parse 16 | jars/zips 17 | -h,--help Show help 18 | -o,--outputDir This is the base directory where we'll place 19 | output 20 | -z,--resizeFactor This is the resize factor. Default is 2. 21 | 22 | #### Attention 23 | 24 | We recommend: 25 | 26 | 1. Install all you favorite plugins prior to icons convertion 27 | 2. Keep original eclipse directory for plugins installations and etc. 28 | 29 | The main reason if that is following: first execution will enlarge 2x, but second execution on already converted files will enlarge 2x one more time 30 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | davidlevy 5 | eclipse-icon-enlarger 6 | 0.0.1-SNAPSHOT 7 | 8 | eclipse-icon-enlarger 9 | 10 | 11 | org.apache.maven.plugins 12 | maven-compiler-plugin 13 | 3.1 14 | 15 | true 16 | 1.6 17 | 1.6 18 | 19 | 20 | 21 | maven-assembly-plugin 22 | 23 | 24 | 25 | enlarger.FixIcons 26 | 27 | 28 | 29 | jar-with-dependencies 30 | 31 | false 32 | 33 | 34 | 35 | make-assembly 36 | package 37 | 38 | single 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | commons-cli 50 | commons-cli 51 | 1.2 52 | 53 | 54 | org.imgscalr 55 | imgscalr-lib 56 | 4.2 57 | jar 58 | compile 59 | 60 | 61 | 62 | com.mortennobel 63 | java-image-scaling 64 | 0.8.5 65 | 66 | 67 | commons-io 68 | commons-io 69 | 2.4 70 | 71 | 72 | commons-lang 73 | commons-lang 74 | 2.4 75 | 76 | 77 | junit 78 | junit 79 | 4.7 80 | test 81 | 82 | 83 | -------------------------------------------------------------------------------- /src/main/java/enlarger/FixIcons.java: -------------------------------------------------------------------------------- 1 | package enlarger; 2 | 3 | import java.io.File; 4 | import java.util.logging.Level; 5 | import java.util.logging.Logger; 6 | 7 | import org.apache.commons.cli.CommandLine; 8 | import org.apache.commons.cli.GnuParser; 9 | import org.apache.commons.cli.HelpFormatter; 10 | import org.apache.commons.cli.Option; 11 | import org.apache.commons.cli.Options; 12 | import org.apache.commons.cli.ParseException; 13 | 14 | /** 15 | * Small utility to double the size of eclipse icons for QHD monitors. 16 | * 17 | * @author David Levy 18 | * @since 2014/04/10 19 | * 20 | */ 21 | public class FixIcons { 22 | 23 | private static final Logger logger = Logger.getGlobal(); 24 | 25 | private static Options options = new Options(); 26 | 27 | static 28 | { 29 | logger.setLevel(Level.INFO); 30 | Option baseDir = new Option("b", "baseDir", true, 31 | "This is the base directory where we'll parse jars/zips"); 32 | Option outputDir = new Option("o", "outputDir", true, 33 | "This is the base directory where we'll place output"); 34 | Option resizeFactor = new Option("z", "resizeFactor", true, 35 | "This is the resize factor. Default is 2."); 36 | Option help = new Option("h", "help", true, 37 | "Show help"); 38 | baseDir.setRequired(true); 39 | outputDir.setRequired(true); 40 | 41 | options.addOption(baseDir); 42 | options.addOption(outputDir); 43 | options.addOption(resizeFactor); 44 | options.addOption(help); 45 | } 46 | 47 | public static final void main(String[] args) { 48 | 49 | try { 50 | GnuParser parser = new GnuParser(); 51 | CommandLine commandLine = parser.parse(options, args); 52 | if(!commandLine.hasOption("b") || !commandLine.hasOption("o") || commandLine.hasOption("h")) 53 | { 54 | printHelp(); 55 | return; 56 | } 57 | 58 | String baseDirArg = commandLine.getOptionValue("b"); 59 | logger.info("Base directory: " + baseDirArg); 60 | 61 | String outputDirArg = commandLine.getOptionValue("o"); 62 | logger.info("Output directory: " + outputDirArg); 63 | 64 | File base = new File(baseDirArg); 65 | if (!base.exists() || !base.canRead() || !base.isDirectory()) { 66 | logger.severe("Unable to read from base directory"); 67 | return; 68 | } 69 | 70 | File output = new File(outputDirArg); 71 | if(!output.exists()) 72 | { 73 | if(!output.mkdirs()) 74 | { 75 | logger.severe("Can't create directory '"+outputDirArg+"'"); 76 | printHelp(); 77 | return; 78 | } 79 | } 80 | if (!output.exists() || !output.canRead() || !output.canWrite() 81 | || !output.isDirectory()) { 82 | logger.severe("Unable to write to output director"); 83 | return; 84 | } 85 | 86 | if (base.list() == null || base.list().length == 0) { 87 | logger.severe("The base directory is empty"); 88 | return; 89 | } 90 | 91 | if (output.list() != null && output.list().length != 0) { 92 | logger.severe("The output directory is not empty"); 93 | return; 94 | } 95 | String resizeFactorStr = commandLine.getOptionValue("z"); 96 | float resizeFactor = 2; 97 | if(resizeFactorStr!=null) 98 | { 99 | try 100 | { 101 | resizeFactor = Float.parseFloat(resizeFactorStr); 102 | } catch (NumberFormatException e) 103 | { 104 | logger.severe("Can't parse provided resizeFactor'" +resizeFactorStr+"'"); 105 | return; 106 | } 107 | } 108 | logger.info("Resize factor: " + resizeFactor); 109 | 110 | new FixIconsProcessor().processDirectory(base, output, resizeFactor); 111 | 112 | } catch (ParseException e) { 113 | logger.severe("Unable to parse arguments: " + e.getMessage()); 114 | printHelp(); 115 | } catch (Exception e) { 116 | logger.log(Level.SEVERE, "Unexpected error: " + e.getMessage(), e); 117 | printHelp(); 118 | } 119 | } 120 | 121 | private static void printHelp() 122 | { 123 | HelpFormatter formatter = new HelpFormatter(); 124 | formatter.printHelp( "java -jar eclipse-icon-enlarger.jar", options ); 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /src/main/java/enlarger/FixIconsProcessor.java: -------------------------------------------------------------------------------- 1 | package enlarger; 2 | 3 | import java.awt.image.BufferedImage; 4 | import java.io.BufferedInputStream; 5 | import java.io.File; 6 | import java.io.FileInputStream; 7 | import java.io.FileOutputStream; 8 | import java.io.IOException; 9 | import java.io.InputStream; 10 | import java.io.OutputStream; 11 | import java.util.Enumeration; 12 | import java.util.logging.Level; 13 | import java.util.logging.Logger; 14 | import java.util.zip.ZipEntry; 15 | import java.util.zip.ZipFile; 16 | import java.util.zip.ZipOutputStream; 17 | 18 | import javax.imageio.ImageIO; 19 | 20 | import org.apache.commons.io.IOUtils; 21 | import org.imgscalr.Scalr; 22 | 23 | import com.mortennobel.imagescaling.AdvancedResizeOp; 24 | import com.mortennobel.imagescaling.ResampleOp; 25 | 26 | public class FixIconsProcessor 27 | { 28 | private static final Logger logger = Logger.getGlobal(); 29 | 30 | public void processDirectory(File directory, File outputDirectory, float resizeFactor) 31 | throws Exception { 32 | logger.info("Processing directory [" + directory.getAbsolutePath() 33 | + "]"); 34 | 35 | for (File file : directory.listFiles()) { 36 | if (file.isDirectory()) { 37 | File targetDir = new File(outputDirectory.getAbsolutePath() 38 | + File.separator + file.getName()); 39 | logger.info("Creating directory: " 40 | + targetDir.getAbsolutePath()); 41 | targetDir.mkdir(); 42 | processDirectory(file, targetDir, resizeFactor); 43 | } else { 44 | File targetFile = new File(outputDirectory.getAbsolutePath() 45 | + File.separator + file.getName()); 46 | 47 | if (file.getName().toLowerCase().endsWith(".zip") 48 | || file.getName().toLowerCase().endsWith(".jar")) { 49 | logger.info("Processing archive file: " 50 | + file.getAbsolutePath()); 51 | ZipFile zipSrc = null; 52 | ZipOutputStream outStream = null; 53 | try 54 | { 55 | zipSrc = new ZipFile(file); 56 | Enumeration srcEntries = zipSrc.entries(); 57 | 58 | outStream = new ZipOutputStream( 59 | new FileOutputStream(targetFile)); 60 | 61 | while (srcEntries.hasMoreElements()) { 62 | ZipEntry entry = (ZipEntry) srcEntries.nextElement(); 63 | logger.info("Processing zip entry [" + entry.getName() 64 | + "]"); 65 | 66 | ZipEntry newEntry = new ZipEntry(entry.getName()); 67 | try { 68 | outStream.putNextEntry(newEntry); 69 | } catch (Exception e) { 70 | if (!e.getMessage().startsWith("duplicate entry: ")) { 71 | logger.log(Level.SEVERE, "Error: ", e); 72 | } else { 73 | logger.log(Level.SEVERE, e.getMessage(), e); 74 | } 75 | outStream.closeEntry(); 76 | continue; 77 | } 78 | 79 | BufferedInputStream bis = new BufferedInputStream( 80 | zipSrc.getInputStream(entry)); 81 | 82 | if (ImageType.findType(entry.getName()) != null) { 83 | processImage(zipSrc.getName() + "!/" + entry.getName(), bis, outStream, resizeFactor); 84 | } else { 85 | IOUtils.copy(bis, outStream); 86 | } 87 | 88 | outStream.closeEntry(); 89 | bis.close(); 90 | } 91 | 92 | } catch (Exception e) 93 | { 94 | logger.log(Level.SEVERE, "Can't process file: "+file.getAbsolutePath(), e); 95 | } 96 | finally 97 | { 98 | try 99 | { 100 | if(zipSrc!=null) zipSrc.close(); 101 | if(outStream!=null) outStream.close(); 102 | } catch (IOException e) 103 | { 104 | logger.log(Level.SEVERE, "Can't close zip streams for file: "+file.getAbsolutePath(), e); 105 | } 106 | } 107 | } else if (ImageType.findType(file.getName()) != null) { 108 | logger.info("Processing image: " + file.getAbsolutePath()); 109 | 110 | FileInputStream inStream = null; 111 | FileOutputStream outStream = null; 112 | 113 | try { 114 | inStream = new FileInputStream(file); 115 | outStream = new FileOutputStream(targetFile); 116 | processImage(file.getName(), inStream, outStream, resizeFactor); 117 | } finally { 118 | IOUtils.closeQuietly(inStream); 119 | IOUtils.closeQuietly(outStream); 120 | } 121 | } else { 122 | logger.info("Processing : " + file.getAbsolutePath()); 123 | 124 | FileInputStream inStream = null; 125 | FileOutputStream outStream = null; 126 | 127 | try { 128 | inStream = new FileInputStream(file); 129 | outStream = new FileOutputStream(targetFile); 130 | IOUtils.copy(inStream, outStream); 131 | } finally { 132 | IOUtils.closeQuietly(inStream); 133 | IOUtils.closeQuietly(outStream); 134 | } 135 | 136 | } 137 | 138 | } 139 | 140 | } 141 | 142 | } 143 | 144 | public void processImage(String fileName, InputStream input, 145 | OutputStream output, float resizeFactor) throws IOException { 146 | 147 | logger.info("Scaling image: " + fileName); 148 | 149 | boolean imageWriteStarted = false; 150 | try { 151 | BufferedImage out = ImageIO.read(input); 152 | 153 | int outWidth = (int) (out.getWidth() * resizeFactor); 154 | int outHeight = (int) (out.getHeight() * resizeFactor); 155 | 156 | BufferedImage rescaledOut = createResizedCopy(out, outWidth, outHeight); 157 | 158 | ImageIO.write(rescaledOut, ImageType.findType(fileName).name(), 159 | output); 160 | 161 | } catch (Exception e) { 162 | if (imageWriteStarted) { 163 | throw new RuntimeException("Failed to scale image [" + fileName 164 | + "]: " + e.getMessage(), e); 165 | } else { 166 | logger.log(Level.SEVERE, 167 | "Unable to scale [" + fileName + "]: " + e.getMessage(), 168 | e); 169 | IOUtils.copy(input, output); 170 | } 171 | } 172 | } 173 | 174 | private BufferedImage createResizedCopy(BufferedImage originalImage, int scaledWidth, int scaledHeight) { 175 | 176 | try { 177 | ResampleOp resampleOp = new ResampleOp(scaledWidth,scaledHeight); 178 | resampleOp.setUnsharpenMask(AdvancedResizeOp.UnsharpenMask.Normal); 179 | BufferedImage scaledBI = resampleOp.filter(originalImage, null); 180 | 181 | return scaledBI; 182 | } catch (RuntimeException e) { 183 | 184 | // Resample failed - maybe the image was too small, try another way (Scalr) 185 | BufferedImage scaledBI = Scalr.resize(originalImage, Scalr.Method.ULTRA_QUALITY, scaledWidth, scaledHeight); 186 | return scaledBI; 187 | } 188 | } 189 | } 190 | -------------------------------------------------------------------------------- /src/main/java/enlarger/ImageType.java: -------------------------------------------------------------------------------- 1 | package enlarger; 2 | 3 | public enum ImageType { 4 | 5 | PNG(".png"), 6 | GIF(".gif"); 7 | 8 | private String suffix; 9 | 10 | private ImageType(String fileName) { 11 | this.suffix = fileName; 12 | } 13 | 14 | public String getFileName() { 15 | return suffix; 16 | } 17 | 18 | public static ImageType findType(String fileName) { 19 | for (ImageType type : values()) { 20 | if (fileName.toLowerCase().endsWith(type.suffix)) { 21 | return type; 22 | } 23 | } 24 | 25 | return null; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | # Root logger option 2 | log4j.rootLogger=WARN, stdout 3 | 4 | # Direct log messages to stdout 5 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 6 | log4j.appender.stdout.Target=System.out 7 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 8 | log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n --------------------------------------------------------------------------------