Skip to content

Commit

Permalink
Merge branch 'release/2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Dolski committed Jan 11, 2016
2 parents 6369e59 + eab58f0 commit 6df3929
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 14 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
<groupId>edu.illinois.library.cantaloupe</groupId>
<artifactId>Cantaloupe</artifactId>
<packaging>jar</packaging>
<version>2.0</version>
<version>2.0.1</version>
<name>Cantaloupe</name>
<url>https://medusa-project.github.io/cantaloupe/</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<cantaloupe.version>2.0</cantaloupe.version>
<cantaloupe.version>2.0.1</cantaloupe.version>
<amazon-s3.version>1.10.43</amazon-s3.version>
<commons-io.version>2.4</commons-io.version>
<commons-lang3.version>3.4</commons-lang3.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -434,10 +434,11 @@ public void purge(Identifier identifier) throws IOException {
}

@Override
public void purge(OperationList ops) throws IOException {
public void purge(OperationList opList) throws IOException {
synchronized (lock1) {
while (purgingInProgress.get() || imagesBeingPurged.contains(ops) ||
imagesBeingWritten.contains(ops)) {
// imagesBeingWritten may also contain this opList, but so be it;
// the delete we're going to do won't interrupt the write.
while (purgingInProgress.get() || imagesBeingPurged.contains(opList)) {
try {
lock1.wait();
} catch (InterruptedException e) {
Expand All @@ -447,22 +448,22 @@ public void purge(OperationList ops) throws IOException {
}

try {
imagesBeingPurged.add(ops);
File imageFile = getImageFile(ops);
imagesBeingPurged.add(opList);
File imageFile = getImageFile(opList);
if (imageFile != null && imageFile.exists()) {
if (!imageFile.delete()) {
throw new IOException("Unable to delete " + imageFile);
}
}
File dimensionFile = getDimensionFile(ops.getIdentifier());
File dimensionFile = getDimensionFile(opList.getIdentifier());
if (dimensionFile != null && dimensionFile.exists()) {
if (!dimensionFile.delete()) {
throw new IOException("Unable to delete " + imageFile);
}
}
logger.info("Purged {}", ops);
logger.info("Purged {}", opList);
} finally {
imagesBeingPurged.remove(ops);
imagesBeingPurged.remove(opList);
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/main/java/edu/illinois/library/cantaloupe/image/Crop.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ public Rectangle getRectangle(Dimension fullSize) {
width = Math.round(this.getWidth());
height = Math.round(this.getHeight());
}
// confine width and height to the source image bounds
width = Math.min(width, fullSize.width - x);
height = Math.min(height, fullSize.height - y);
return new Rectangle(x, y, width, height);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -441,8 +441,8 @@ public static RenderedOp scaleImage(RenderedOp inImage, Scale scale,
} else if (scale.getMode() == Scale.Mode.ASPECT_FIT_INSIDE) {
double hScale = scale.getWidth() / sourceWidth;
double vScale = scale.getHeight() / sourceHeight;
xScale = sourceWidth * Math.min(hScale, vScale);
yScale = sourceHeight * Math.min(hScale, vScale);
xScale = (sourceWidth * Math.min(hScale, vScale)) / 100f;
yScale = (sourceHeight * Math.min(hScale, vScale)) / 100f;
} else if (scale.getPercent() != null) {
int reqRf = ProcessorUtil.
getReductionFactor(scale.getPercent(), 0).factor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public ImageRepresentation(MediaType mediaType,
*/
@Override
public void write(WritableByteChannel writableChannel) throws IOException {
Cache cache = CacheFactory.getInstance();
final Cache cache = CacheFactory.getInstance();
try {
if (cache != null) {
WritableByteChannel cacheWritableChannel = null;
Expand Down Expand Up @@ -148,7 +148,7 @@ private void doCacheAwareWrite(TeeWritableByteChannel writableChannel,
try {
doWrite(writableChannel);
} catch (IOException e) {
logger.info(e.getMessage(), e);
logger.info(e.getMessage());
cache.purge(this.ops);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ public void testGetRectangle() {
crop.setWidth(0.5f);
crop.setHeight(0.5f);
assertEquals(new Rectangle(40, 40, 100, 100), crop.getRectangle(fullSize));
// test that the resulting rectangle does not clip the full-size bounds
crop = new Crop();
crop.setX(150f);
crop.setY(150f);
crop.setWidth(100f);
crop.setHeight(100f);
assertEquals(new Rectangle(150, 150, 50, 50), crop.getRectangle(fullSize));
}

@Test
Expand Down
8 changes: 8 additions & 0 deletions website/changes.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@

<h2>Change Log</h2>

<h3>2.0.1</h3>

<ul>
<li>Fixed FilesystemCache failing to delete incompletely-written images (as due to e.g. a broken connection).</li>
<li>Fixed a Java2dProcessor cropping bug affecting PNG and GIF source formats.</li>
<li>Fixed a JaiProcessor scale-to-fit-inside bug.</li>
</ul>

<h3>2.0</h3>

<ul>
Expand Down

0 comments on commit 6df3929

Please sign in to comment.