summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--build.xml20
-rw-r--r--docs/screenshots/image_processing.txt11
-rw-r--r--docs/screenshots/raw/00.pngbin148301 -> 0 bytes
-rw-r--r--docs/screenshots/raw/01.pngbin77693 -> 0 bytes
-rw-r--r--docs/screenshots/raw/02.pngbin82789 -> 0 bytes
-rw-r--r--docs/screenshots/raw/03.pngbin135243 -> 0 bytes
-rw-r--r--docs/screenshots/raw/04.pngbin153478 -> 0 bytes
-rw-r--r--docs/screenshots/raw/05.pngbin118476 -> 0 bytes
-rw-r--r--docs/screenshots/raw/06.pngbin122360 -> 0 bytes
-rw-r--r--docs/screenshots/raw/07.pngbin124989 -> 0 bytes
-rw-r--r--docs/screenshots/raw/08.pngbin125687 -> 0 bytes
-rw-r--r--docs/screenshots/thumbs/00.pngbin38921 -> 0 bytes
-rw-r--r--docs/screenshots/thumbs/01.pngbin8915 -> 0 bytes
-rw-r--r--docs/screenshots/thumbs/02.pngbin11668 -> 0 bytes
-rw-r--r--docs/screenshots/thumbs/03.pngbin30422 -> 0 bytes
-rw-r--r--docs/screenshots/thumbs/04.pngbin36996 -> 0 bytes
-rw-r--r--docs/screenshots/thumbs/05.pngbin17965 -> 0 bytes
-rw-r--r--docs/screenshots/thumbs/06.pngbin28605 -> 0 bytes
-rw-r--r--docs/screenshots/thumbs/07.pngbin30671 -> 0 bytes
-rw-r--r--docs/screenshots/thumbs/08.pngbin29744 -> 0 bytes
-rw-r--r--src/com/gitblit/Thumbnailer.java134
21 files changed, 153 insertions, 12 deletions
diff --git a/build.xml b/build.xml
index c41b788a..ddb0dfbf 100644
--- a/build.xml
+++ b/build.xml
@@ -135,13 +135,19 @@
</fileset>
</copy>
- <!-- Copy screenshot thumbnails -->
- <mkdir dir="${basedir}/site/thumbs" />
- <copy todir="${basedir}/site/thumbs">
- <fileset dir="${basedir}/docs/screenshots/thumbs">
- <include name="*.png" />
- </fileset>
- </copy>
+ <!-- Generate thumbnails of screenshots -->
+ <java classpath="${project.build.dir}" classname="com.gitblit.Thumbnailer">
+ <classpath refid="master-classpath" />
+
+ <arg value="--sourceFolder" />
+ <arg value="${basedir}/docs/screenshots" />
+
+ <arg value="--destinationFolder" />
+ <arg value="${basedir}/site/thumbs" />
+
+ <arg value="--maximumDimension" />
+ <arg value="250" />
+ </java>
<!-- Copy screenshots -->
<mkdir dir="${basedir}/site/screenshots" />
diff --git a/docs/screenshots/image_processing.txt b/docs/screenshots/image_processing.txt
index de1d102b..d034062c 100644
--- a/docs/screenshots/image_processing.txt
+++ b/docs/screenshots/image_processing.txt
@@ -1,5 +1,6 @@
-1. Install GIMP
-2. Download and install David's Batch Processor (DBP) http://members.ozemail.com.au/~hodsond/dbp.html
-3. Make screenshots and put them in "screenshots\raw"
-4. Using DBP, crop the images to 1007x661 and output PNGs to "screenshots"
-5. Using DBP, resize the cropped images to 0.25 with a blur of 1.0 and put PNGs in "screenshots\thumbs" \ No newline at end of file
+1. Install Firefox
+2. Install "Awesome Screenshot" add-on
+3. Set browser size to 1024x768
+4. Save "visible part" screenshots as png to screenshots folder
+
+Screenshot thumbnails are automatically generated during build script execution. \ No newline at end of file
diff --git a/docs/screenshots/raw/00.png b/docs/screenshots/raw/00.png
deleted file mode 100644
index eb501496..00000000
--- a/docs/screenshots/raw/00.png
+++ /dev/null
Binary files differ
diff --git a/docs/screenshots/raw/01.png b/docs/screenshots/raw/01.png
deleted file mode 100644
index e626edf0..00000000
--- a/docs/screenshots/raw/01.png
+++ /dev/null
Binary files differ
diff --git a/docs/screenshots/raw/02.png b/docs/screenshots/raw/02.png
deleted file mode 100644
index 8578ca6b..00000000
--- a/docs/screenshots/raw/02.png
+++ /dev/null
Binary files differ
diff --git a/docs/screenshots/raw/03.png b/docs/screenshots/raw/03.png
deleted file mode 100644
index 0fc03518..00000000
--- a/docs/screenshots/raw/03.png
+++ /dev/null
Binary files differ
diff --git a/docs/screenshots/raw/04.png b/docs/screenshots/raw/04.png
deleted file mode 100644
index d2c16651..00000000
--- a/docs/screenshots/raw/04.png
+++ /dev/null
Binary files differ
diff --git a/docs/screenshots/raw/05.png b/docs/screenshots/raw/05.png
deleted file mode 100644
index a2fe4094..00000000
--- a/docs/screenshots/raw/05.png
+++ /dev/null
Binary files differ
diff --git a/docs/screenshots/raw/06.png b/docs/screenshots/raw/06.png
deleted file mode 100644
index 4dfc2690..00000000
--- a/docs/screenshots/raw/06.png
+++ /dev/null
Binary files differ
diff --git a/docs/screenshots/raw/07.png b/docs/screenshots/raw/07.png
deleted file mode 100644
index 0b7c4120..00000000
--- a/docs/screenshots/raw/07.png
+++ /dev/null
Binary files differ
diff --git a/docs/screenshots/raw/08.png b/docs/screenshots/raw/08.png
deleted file mode 100644
index 9c37663d..00000000
--- a/docs/screenshots/raw/08.png
+++ /dev/null
Binary files differ
diff --git a/docs/screenshots/thumbs/00.png b/docs/screenshots/thumbs/00.png
deleted file mode 100644
index 636631ff..00000000
--- a/docs/screenshots/thumbs/00.png
+++ /dev/null
Binary files differ
diff --git a/docs/screenshots/thumbs/01.png b/docs/screenshots/thumbs/01.png
deleted file mode 100644
index 66bd6d0e..00000000
--- a/docs/screenshots/thumbs/01.png
+++ /dev/null
Binary files differ
diff --git a/docs/screenshots/thumbs/02.png b/docs/screenshots/thumbs/02.png
deleted file mode 100644
index 316be989..00000000
--- a/docs/screenshots/thumbs/02.png
+++ /dev/null
Binary files differ
diff --git a/docs/screenshots/thumbs/03.png b/docs/screenshots/thumbs/03.png
deleted file mode 100644
index e141348b..00000000
--- a/docs/screenshots/thumbs/03.png
+++ /dev/null
Binary files differ
diff --git a/docs/screenshots/thumbs/04.png b/docs/screenshots/thumbs/04.png
deleted file mode 100644
index eeee2ecb..00000000
--- a/docs/screenshots/thumbs/04.png
+++ /dev/null
Binary files differ
diff --git a/docs/screenshots/thumbs/05.png b/docs/screenshots/thumbs/05.png
deleted file mode 100644
index c60dc587..00000000
--- a/docs/screenshots/thumbs/05.png
+++ /dev/null
Binary files differ
diff --git a/docs/screenshots/thumbs/06.png b/docs/screenshots/thumbs/06.png
deleted file mode 100644
index 3e278909..00000000
--- a/docs/screenshots/thumbs/06.png
+++ /dev/null
Binary files differ
diff --git a/docs/screenshots/thumbs/07.png b/docs/screenshots/thumbs/07.png
deleted file mode 100644
index 4212d302..00000000
--- a/docs/screenshots/thumbs/07.png
+++ /dev/null
Binary files differ
diff --git a/docs/screenshots/thumbs/08.png b/docs/screenshots/thumbs/08.png
deleted file mode 100644
index 7432d3f0..00000000
--- a/docs/screenshots/thumbs/08.png
+++ /dev/null
Binary files differ
diff --git a/src/com/gitblit/Thumbnailer.java b/src/com/gitblit/Thumbnailer.java
new file mode 100644
index 00000000..5976f25e
--- /dev/null
+++ b/src/com/gitblit/Thumbnailer.java
@@ -0,0 +1,134 @@
+/*
+ * Copyright 2011 gitblit.com.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gitblit;
+
+import java.awt.Dimension;
+import java.awt.Image;
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.util.Iterator;
+
+import javax.imageio.ImageIO;
+import javax.imageio.ImageReader;
+import javax.imageio.stream.ImageInputStream;
+
+import com.beust.jcommander.JCommander;
+import com.beust.jcommander.Parameter;
+import com.beust.jcommander.ParameterException;
+import com.beust.jcommander.Parameters;
+
+public class Thumbnailer {
+
+ public static void main(String[] args) {
+ Params params = new Params();
+ JCommander jc = new JCommander(params);
+ try {
+ jc.parse(args);
+ } catch (ParameterException t) {
+ System.err.println(t.getMessage());
+ jc.usage();
+ }
+ createImageThumbnail(params.sourceFolder, params.destinationFolder, params.maximumDimension);
+ }
+
+ public static void createImageThumbnail(String sourceFolder, String destinationFolder,
+ int maxDimension) {
+ if (maxDimension <= 0)
+ return;
+ File source = new File(sourceFolder);
+ File destination = new File(destinationFolder);
+ destination.mkdirs();
+ File[] sourceFiles = source.listFiles(new FilenameFilter() {
+ @Override
+ public boolean accept(File dir, String name) {
+ return name.toLowerCase().endsWith(".png");
+ }
+ });
+
+ for (File sourceFile : sourceFiles) {
+ File destinationFile = new File(destination, sourceFile.getName());
+ try {
+ Dimension sz = getImageDimensions(sourceFile);
+ int w = 0;
+ int h = 0;
+ if (sz.width > maxDimension) {
+ // Scale to Width
+ w = maxDimension;
+ float f = maxDimension;
+ h = (int) ((f / sz.width) * sz.height); // normalize height
+ } else if (sz.height > maxDimension) {
+ // Scale to Height
+ h = maxDimension;
+ float f = maxDimension;
+ w = (int) ((f / sz.height) * sz.width); // normalize width
+ } else {
+ // No thumbnail
+ return;
+ }
+ System.out.println("Generating thumbnail for " + sourceFile.getName() + " as (" + w
+ + "," + h + ")");
+ BufferedImage image = ImageIO.read(sourceFile);
+ Image scaledImage = image.getScaledInstance(w, h, BufferedImage.SCALE_SMOOTH);
+ BufferedImage destImage = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
+ destImage.createGraphics().drawImage(scaledImage, 0, 0, null);
+ FileOutputStream fos = new FileOutputStream(destinationFile);
+ ImageIO.write(destImage, "png", fos);
+ fos.flush();
+ fos.getFD().sync();
+ fos.close();
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
+ }
+ }
+
+ public static Dimension getImageDimensions(File file) throws IOException {
+ ImageInputStream in = ImageIO.createImageInputStream(file);
+ try {
+ final Iterator<ImageReader> readers = ImageIO.getImageReaders(in);
+ if (readers.hasNext()) {
+ ImageReader reader = readers.next();
+ try {
+ reader.setInput(in);
+ return new Dimension(reader.getWidth(0), reader.getHeight(0));
+ } finally {
+ reader.dispose();
+ }
+ }
+ } finally {
+ if (in != null)
+ in.close();
+ }
+ return null;
+ }
+
+ @Parameters(separators = " ")
+ private static class Params {
+
+ @Parameter(names = { "--sourceFolder" }, description = "Source folder for raw images", required = true)
+ public String sourceFolder;
+
+ @Parameter(names = { "--destinationFolder" }, description = "Destination folder for thumbnails", required = true)
+ public String destinationFolder;
+
+ @Parameter(names = { "--maxDimension" }, description = "Maximum width or height for thumbnail", required = true)
+ public int maximumDimension;
+
+ }
+}