Преглед на файлове

Simplified screenshot process and automated thumbnail generation.

tags/v0.5.0
James Moger преди 13 години
родител
ревизия
24d08fb7be
променени са 21 файла, в които са добавени 153 реда и са изтрити 12 реда
  1. 13
    7
      build.xml
  2. 6
    5
      docs/screenshots/image_processing.txt
  3. Двоични данни
      docs/screenshots/raw/00.png
  4. Двоични данни
      docs/screenshots/raw/01.png
  5. Двоични данни
      docs/screenshots/raw/02.png
  6. Двоични данни
      docs/screenshots/raw/03.png
  7. Двоични данни
      docs/screenshots/raw/04.png
  8. Двоични данни
      docs/screenshots/raw/05.png
  9. Двоични данни
      docs/screenshots/raw/06.png
  10. Двоични данни
      docs/screenshots/raw/07.png
  11. Двоични данни
      docs/screenshots/raw/08.png
  12. Двоични данни
      docs/screenshots/thumbs/00.png
  13. Двоични данни
      docs/screenshots/thumbs/01.png
  14. Двоични данни
      docs/screenshots/thumbs/02.png
  15. Двоични данни
      docs/screenshots/thumbs/03.png
  16. Двоични данни
      docs/screenshots/thumbs/04.png
  17. Двоични данни
      docs/screenshots/thumbs/05.png
  18. Двоични данни
      docs/screenshots/thumbs/06.png
  19. Двоични данни
      docs/screenshots/thumbs/07.png
  20. Двоични данни
      docs/screenshots/thumbs/08.png
  21. 134
    0
      src/com/gitblit/Thumbnailer.java

+ 13
- 7
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" />

+ 6
- 5
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"
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.

Двоични данни
docs/screenshots/raw/00.png Целия файл


Двоични данни
docs/screenshots/raw/01.png Целия файл


Двоични данни
docs/screenshots/raw/02.png Целия файл


Двоични данни
docs/screenshots/raw/03.png Целия файл


Двоични данни
docs/screenshots/raw/04.png Целия файл


Двоични данни
docs/screenshots/raw/05.png Целия файл


Двоични данни
docs/screenshots/raw/06.png Целия файл


Двоични данни
docs/screenshots/raw/07.png Целия файл


Двоични данни
docs/screenshots/raw/08.png Целия файл


Двоични данни
docs/screenshots/thumbs/00.png Целия файл


Двоични данни
docs/screenshots/thumbs/01.png Целия файл


Двоични данни
docs/screenshots/thumbs/02.png Целия файл


Двоични данни
docs/screenshots/thumbs/03.png Целия файл


Двоични данни
docs/screenshots/thumbs/04.png Целия файл


Двоични данни
docs/screenshots/thumbs/05.png Целия файл


Двоични данни
docs/screenshots/thumbs/06.png Целия файл


Двоични данни
docs/screenshots/thumbs/07.png Целия файл


Двоични данни
docs/screenshots/thumbs/08.png Целия файл


+ 134
- 0
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;
}
}

Loading…
Отказ
Запис