Skip to content

Commit

Permalink
Implemented rotate-before-upload based on jpegtran.
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre-Luc Paour committed Jun 16, 2003
1 parent 0000e6d commit 8b5d84e
Show file tree
Hide file tree
Showing 10 changed files with 267 additions and 186 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
@@ -1,3 +1,7 @@
2003-06-16 Pierre-Luc Paour <gallery@paour.com> (1.1-b6)

* Implemented rotate-before-upload based on jpegtran.

2003-06-16 Pierre-Luc Paour <gallery@paour.com> (1.1-b5)

* Truncating long URLs in UI to make it nicer when CMS URLs are
Expand Down
8 changes: 7 additions & 1 deletion ReadMe.html
Expand Up @@ -61,7 +61,7 @@
<h1 align="center">Gallery Remote ReadMe</h1>
<p>Version: 1.1<br>
Last modified:
<!-- #BeginDate format:Am1 -->June 13, 2003<!-- #EndDate -->
<!-- #BeginDate format:Am1 -->June 16, 2003<!-- #EndDate -->
</p>
<h2 align="left">Contents</h2>

Expand Down Expand Up @@ -166,6 +166,12 @@ <h3>JSX</h3>
allow external tools to automatically generate projects that can then be loaded
into Gallery Remote.</p>
<p>JSX is licensed under the GPL.</p>
<h3>Jpegtran</h3>
<p>The Win32 version of Jpegtran, compiled and patched by <a href="http://sylvana.net/jpegcrop/">Guido
Vollbeding</a> is bundled. We use Jpegtran to rotate pictures before upload.
In the future, it may also be used to crop pictures.</p>
<p>Jpegtran doesn't appear to have any particular license, but is obviously redistributable,
since it comes with most Linux distributions. Guido's version is freely downloadable.</p>
<h2><a name="problems"></a>Known problems</h2>
<p>There are many, I am sure.</p>
<p>Right now, the lack of out of the box support for ImageMagick on non-Windows
Expand Down
16 changes: 13 additions & 3 deletions com/gallery/GalleryRemote/GalleryFileFilter.java
Expand Up @@ -35,7 +35,11 @@ public class GalleryFileFilter extends FileFilter {
public static String[] ext1
= { "gif", "jpeg", "jpg", "png" };
public static final List manipulateExtensions = Arrays.asList( ext1 );


public static String[] ext2
= { "jpg", "png" };
public static final List manipulateJpegExtensions = Arrays.asList( ext2 );

// Accept all directories and all gif, jpg files.
public boolean accept(File f) {
if (f.isDirectory()) {
Expand All @@ -49,10 +53,16 @@ public boolean accept(File f) {

public static boolean canManipulate(String filename) {
String extension = getExtension(filename);

return ( extension != null && manipulateExtensions.contains(extension) );
}


public static boolean canManipulateJpeg(String filename) {
String extension = getExtension(filename);

return ( extension != null && manipulateJpegExtensions.contains(extension) );
}

// The description of this filter
public String getDescription() {
return "Gallery Items";
Expand Down
39 changes: 2 additions & 37 deletions com/gallery/GalleryRemote/MainFrame.java
Expand Up @@ -284,8 +284,7 @@ && getCurrentGallery().getComm(MainFrame.this).isLoggedIn()) {

if ( GalleryRemote.getInstance().properties.getShowPreview() ) {
if ( sel != -1 ) {
String filename = ( getCurrentAlbum().getPicture( sel ).getSource() ).getPath();
previewFrame.displayFile( filename );
previewFrame.displayFile( getCurrentAlbum().getPicture( sel ) );
} else {
previewFrame.displayFile( null );
}
Expand Down Expand Up @@ -697,41 +696,7 @@ public ImageIcon getThumbnail( String filename ) {
public ImageIcon getThumbnail( Picture p ) {
ImageIcon thumb = getThumbnail( p.getSource().getPath() );

if (p.getAngle() != 0 || p.isFlipped()) {
int width;
int height;
int width1;
int height1;

width = thumb.getImage().getWidth(this);
height = thumb.getImage().getHeight(this);

if (p.getAngle() % 2 == 0) {
width1 = width;
height1 = height;
} else {
width1 = height;
height1 = width;
}

Image vImg = getGlassPane().createImage(width1, height1);

Graphics2D g = (Graphics2D) vImg.getGraphics();

AffineTransform transform = AffineTransform.getTranslateInstance(width / 2, height / 2);
if (p.getAngle() != 0) {
transform.rotate(p.getAngle() * Math.PI / 2);
}
if (p.isFlipped()) {
transform.scale(-1, 1);
}
transform.translate(-width1 / 2 - (p.getAngle() == 3?width - width1:0) + (p.isFlipped()?width - width1:0) * (p.getAngle() == 1?-1:1),
-height1 / 2 - (p.getAngle() == 1?height - height1:0));

g.drawImage(thumb.getImage(), transform, this);

thumb = new ImageIcon(vImg);
}
thumb = ImageUtils.rotateImageIcon(thumb, p.getAngle(), p.isFlipped(), getGlassPane());

return thumb;
}
Expand Down
3 changes: 3 additions & 0 deletions com/gallery/GalleryRemote/PictureInspector.java
Expand Up @@ -243,18 +243,21 @@ public void actionPerformed( ActionEvent e ) {
}
setPictures(pictures);
mf.repaint();
mf.previewFrame.repaint();
} else if ( command.equals( "Right" ) ) {
for (int i = 0; i < pictures.length; i++) {
((Picture) pictures[i]).rotateRight();
}
setPictures(pictures);
mf.repaint();
mf.previewFrame.repaint();
} else if ( command.equals( "Flip" ) ) {
for (int i = 0; i < pictures.length; i++) {
((Picture) pictures[i]).flip();
}
setPictures(pictures);
mf.repaint();
mf.previewFrame.repaint();
}
}

Expand Down

0 comments on commit 8b5d84e

Please sign in to comment.