ATS-671: Split engines into fat & skinny modules (ATS-674) (#192)

Each transform engine project has been separated into 2 modules so that an executable and non-executable jar can be created. 
Modules have been renamed such that *docker* has been removed from the artifactIds and project names.

Co-authored-by: Erik Knizat <erik.knizat@alfresco.com>
Co-authored-by: David Edwards <david.edwards@alfresco.com>
This commit is contained in:
eknizat
2020-03-27 13:45:15 +00:00
committed by GitHub
parent 46b2e6df5b
commit 3bed6930bf
215 changed files with 539 additions and 157 deletions

View File

@@ -0,0 +1,42 @@
# Image provides a container in which to run ImageMagick transformations for Alfresco Content Services.
# ImageMagick is from ImageMagick Studio LLC. See the license at http://www.imagemagick.org/script/license.php or in /ImageMagick-license.txt.
FROM alfresco/alfresco-base-java:11.0.1-openjdk-centos-7-72b88c6f1f4c
ARG IMAGEMAGICK_VERSION=7.0.7-27
ENV IMAGEMAGICK_RPM_URL=https://nexus.alfresco.com/nexus/service/local/repositories/thirdparty/content/org/imagemagick/imagemagick-distribution/${IMAGEMAGICK_VERSION}/imagemagick-distribution-${IMAGEMAGICK_VERSION}-linux.rpm
ENV IMAGEMAGICK_LIB_RPM_URL=https://nexus.alfresco.com/nexus/service/local/repositories/thirdparty/content/org/imagemagick/imagemagick-distribution/${IMAGEMAGICK_VERSION}/imagemagick-distribution-${IMAGEMAGICK_VERSION}-libs-linux.rpm
ENV IMAGEMAGICK_LICENSE_FILE=https://github.com/Alfresco/acs-community-packaging/blob/master/distribution/src/main/resources/licenses/3rd-party/ImageMagick-license.txt
ENV JAVA_OPTS=""
# Set default user information
ARG GROUPNAME=Alfresco
ARG GROUPID=1000
ARG IMAGEUSERNAME=imagemagick
ARG USERID=33002
COPY target/${env.project_artifactId}-${env.project_version}.jar /usr/bin
RUN ln /usr/bin/${env.project_artifactId}-${env.project_version}.jar /usr/bin/${env.project_artifactId}.jar && \
curl -s -S $IMAGEMAGICK_RPM_URL -o imagemagick-distribution-linux.rpm && \
curl -s -S $IMAGEMAGICK_LIB_RPM_URL -o imagemagick-distribution-libs-linux.rpm && \
curl -s -S $IMAGEMAGICK_LICENSE_FILE -o ImageMagick-license.txt && \
yum localinstall -y imagemagick-distribution-*linux.rpm && \
rm -f imagemagick-distribution-*.rpm && \
yum clean all
ADD target/generated-resources/licenses /licenses
ADD target/generated-resources/licenses.xml /licenses/
ADD target/generated-sources/license/THIRD-PARTY.txt /licenses/
RUN groupadd -g ${GROUPID} ${GROUPNAME} && \
useradd -u ${USERID} -G ${GROUPNAME} ${IMAGEUSERNAME} && \
chgrp -R ${GROUPNAME} /usr/bin/${env.project_artifactId}.jar
EXPOSE 8090
USER ${IMAGEUSERNAME}
ENTRYPOINT java $JAVA_OPTS -jar /usr/bin/${env.project_artifactId}.jar

View File

@@ -0,0 +1,291 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>alfresco-transform-imagemagick-boot</artifactId>
<name>Alfresco ImageMagick Transformer SpringBoot</name>
<packaging>jar</packaging>
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-transform-core</artifactId>
<version>2.2.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<properties>
<image.name>alfresco/alfresco-imagemagick</image.name>
<image.registry>quay.io</image.registry>
<env.project_artifactId>${project.artifactId}</env.project_artifactId>
</properties>
<dependencies>
<dependency>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-transformer-base</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-transformer-base</artifactId>
<version>${project.version}</version>
<classifier>tests</classifier>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-transform-imagemagick</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>com.vaadin.external.google</groupId>
<artifactId>android-json</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.dom4j</groupId>
<artifactId>dom4j</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>license-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>docker-it-setup</id>
<!-- raises an ActiveMq container for the Integration Tests -->
<build>
<plugins>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<configuration>
<images>
<image>
<alias>activemq</alias>
<name>alfresco/alfresco-activemq:5.15.8</name>
<run>
<hostname>activemq</hostname>
<ports>
<port>8161:8161</port>
<port>5672:5672</port>
<port>61616:61616</port>
</ports>
<wait>
<log>Apache ActiveMQ 5.15.8 .* started</log>
<time>20000</time>
<kill>500</kill>
<shutdown>100</shutdown>
<exec>
<preStop>kill 1</preStop>
<preStop>kill -9 1</preStop>
</exec>
</wait>
</run>
</image>
<image>
<alias>imagemagick</alias>
<name>${image.name}:${image.tag}</name>
<run>
<ports>
<port>8090:8090</port>
</ports>
<wait>
<http>
<url>http://localhost:8090/transform/config</url>
<method>GET</method>
<status>200...299</status>
</http>
<time>300000</time>
<kill>500</kill>
<shutdown>100</shutdown>
<exec>
<preStop>kill 1</preStop>
<preStop>kill -9 1</preStop>
</exec>
</wait>
</run>
</image>
</images>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>local</id>
<build>
<plugins>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>fabric8-maven-plugin</artifactId>
<configuration>
<images>
<image>
<name>${image.name}:${image.tag}</name>
<build>
<dockerFileDir>${project.basedir}/</dockerFileDir>
<buildOptions>
<squash>true</squash>
</buildOptions>
</build>
</image>
</images>
</configuration>
<executions>
<execution>
<id>build-image</id>
<phase>package</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>internal</id>
<build>
<plugins>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>fabric8-maven-plugin</artifactId>
<configuration>
<images>
<!-- QuayIO image -->
<image>
<name>${image.name}:${image.tag}</name>
<registry>${image.registry}</registry>
<build>
<dockerFileDir>${project.basedir}/</dockerFileDir>
<buildOptions>
<squash>true</squash>
</buildOptions>
</build>
</image>
<!-- DockerHub image -->
<image>
<name>${image.name}:${image.tag}</name>
<build>
<dockerFileDir>${project.basedir}/</dockerFileDir>
<buildOptions>
<squash>true</squash>
</buildOptions>
</build>
</image>
</images>
</configuration>
<executions>
<execution>
<id>build-image</id>
<phase>package</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
<execution>
<id>push-image</id>
<phase>install</phase>
<goals>
<goal>push</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>release</id>
<build>
<plugins>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>fabric8-maven-plugin</artifactId>
<configuration combine.self="override">
<images>
<!-- QuayIO image -->
<image>
<name>${image.name}:${project.version}</name>
<registry>${image.registry}</registry>
<build>
<dockerFileDir>${project.basedir}/</dockerFileDir>
<buildOptions>
<squash>true</squash>
</buildOptions>
</build>
</image>
<!-- DockerHub image -->
<image>
<name>${image.name}:${project.version}</name>
<build>
<dockerFileDir>${project.basedir}/</dockerFileDir>
<buildOptions>
<squash>true</squash>
</buildOptions>
</build>
</image>
</images>
</configuration>
<executions>
<execution>
<id>build-push-image</id>
<phase>deploy</phase>
<goals>
<goal>build</goal>
<goal>push</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

View File

@@ -0,0 +1,77 @@
/*
* #%L
* Alfresco Transform Core
* %%
* Copyright (C) 2005 - 2019 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* -
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* -
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.transformer;
import static org.alfresco.transformer.logging.StandardMessages.LICENCE;
import java.util.Arrays;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.actuate.autoconfigure.metrics.MeterRegistryCustomizer;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.annotation.Bean;
import org.springframework.context.event.EventListener;
import io.micrometer.core.instrument.MeterRegistry;
@SpringBootApplication
@EnableAutoConfiguration(exclude = {DataSourceAutoConfiguration.class})
public class Application
{
private static final Logger logger = LoggerFactory.getLogger(Application.class);
@Value("${container.name}")
private String containerName;
@Bean
MeterRegistryCustomizer<MeterRegistry> metricsCommonTags()
{
return registry -> registry.config().commonTags("containerName", containerName);
}
public static void main(String[] args)
{
SpringApplication.run(Application.class, args);
}
@EventListener(ApplicationReadyEvent.class)
public void startup()
{
logger.info("--------------------------------------------------------------------------------------------------------------------------------------------------------------");
Arrays.stream(LICENCE.split("\\n")).forEach(logger::info);
logger.info("This transformer uses ImageMagick from ImageMagick Studio LLC. See the license at http://www.imagemagick.org/script/license.php or in /ImageMagick-license.txt");
logger.info("--------------------------------------------------------------------------------------------------------------------------------------------------------------");
logger.info("Starting application components... Done");
}
}

View File

@@ -0,0 +1,237 @@
/*
* #%L
* Alfresco Transform Core
* %%
* Copyright (C) 2005 - 2019 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* -
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* -
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.transformer;
import static org.alfresco.transformer.fs.FileManager.createAttachment;
import static org.alfresco.transformer.fs.FileManager.createSourceFile;
import static org.alfresco.transformer.fs.FileManager.createTargetFile;
import static org.alfresco.transformer.fs.FileManager.createTargetFileName;
import static org.alfresco.transformer.util.Util.stringToInteger;
import static org.springframework.http.HttpStatus.OK;
import static org.springframework.http.MediaType.MULTIPART_FORM_DATA_VALUE;
import java.io.File;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.alfresco.transformer.executors.ImageMagickCommandExecutor;
import org.alfresco.transformer.logging.LogEntry;
import org.alfresco.transformer.probes.ProbeTestTransform;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.Resource;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
/**
* Controller for the Docker based ImageMagick transformer.
*
*
* Status Codes:
*
* 200 Success
* 400 Bad Request: Invalid cropGravity value (North, NorthEast, East, SouthEast, South, SouthWest, West, NorthWest, Center)
* 400 Bad Request: Request parameter <name> is missing (missing mandatory parameter)
* 400 Bad Request: Request parameter <name> is of the wrong type
* 400 Bad Request: Transformer exit code was not 0 (possible problem with the source file)
* 400 Bad Request: The source filename was not supplied
* 500 Internal Server Error: (no message with low level IO problems)
* 500 Internal Server Error: The target filename was not supplied (should not happen as targetExtension is checked)
* 500 Internal Server Error: Transformer version check exit code was not 0
* 500 Internal Server Error: Transformer version check failed to create any output
* 500 Internal Server Error: Could not read the target file
* 500 Internal Server Error: The target filename was malformed (should not happen because of other checks)
* 500 Internal Server Error: Transformer failed to create an output file (the exit code was 0, so there should be some content)
* 500 Internal Server Error: Filename encoding error
* 507 Insufficient Storage: Failed to store the source file
*/
@Controller
public class ImageMagickController extends AbstractTransformerController
{
private static final Logger logger = LoggerFactory.getLogger(ImageMagickController.class);
private ImageMagickCommandExecutor commandExecutor = new ImageMagickCommandExecutor();
@Override
public String getTransformerName()
{
return "ImageMagick";
}
@Override
public String version()
{
return commandExecutor.version();
}
@Override
public ProbeTestTransform getProbeTestTransform()
{
// See the Javadoc on this method and Probes.md for the choice of these values.
return new ProbeTestTransform(this, "quick.jpg", "quick.png",
35593, 1024, 150, 1024, 60 * 15 + 1, 60 * 15)
{
@Override
protected void executeTransformCommand(File sourceFile, File targetFile)
{
commandExecutor.run("", sourceFile, "", targetFile, null);
}
};
}
@PostMapping(value = "/transform", consumes = MULTIPART_FORM_DATA_VALUE)
public ResponseEntity<Resource> transform(HttpServletRequest request,
@RequestParam("file") MultipartFile sourceMultipartFile,
@RequestParam("targetExtension") String targetExtension,
@RequestParam(value = "timeout", required = false) Long timeout,
@RequestParam(value = "testDelay", required = false) Long testDelay,
@RequestParam(value = "startPage", required = false) Integer startPage,
@RequestParam(value = "endPage", required = false) Integer endPage,
@RequestParam(value = "alphaRemove", required = false) Boolean alphaRemove,
@RequestParam(value = "autoOrient", required = false) Boolean autoOrient,
@RequestParam(value = "cropGravity", required = false) String cropGravity,
@RequestParam(value = "cropWidth", required = false) Integer cropWidth,
@RequestParam(value = "cropHeight", required = false) Integer cropHeight,
@RequestParam(value = "cropPercentage", required = false) Boolean cropPercentage,
@RequestParam(value = "cropXOffset", required = false) Integer cropXOffset,
@RequestParam(value = "cropYOffset", required = false) Integer cropYOffset,
@RequestParam(value = "thumbnail", required = false) Boolean thumbnail,
@RequestParam(value = "resizeWidth", required = false) Integer resizeWidth,
@RequestParam(value = "resizeHeight", required = false) Integer resizeHeight,
@RequestParam(value = "resizePercentage", required = false) Boolean resizePercentage,
@RequestParam(value = "allowEnlargement", required = false) Boolean allowEnlargement,
@RequestParam(value = "maintainAspectRatio", required = false) Boolean maintainAspectRatio,
// The commandOptions parameter is supported in ACS 6.0.1 because there may be
// custom renditions that use it. However the Transform service should
// not support it as it provides the option to specify arbitrary command
// options or even the option to run something else on the command line.
// All Transform service options should be checked as is done for the other
// request parameters. Setting this option in the rendition's
// ImageTransformationOptions object is being deprecated for the point where
// The Transform service is being used for all transforms. In the case of
// ACS 6.0, this is relatively safe as it requires an AMP to be installed
// which supplies the commandOptions.
@RequestParam(value = "commandOptions", required = false) String commandOptions)
{
String targetFilename = createTargetFileName(sourceMultipartFile.getOriginalFilename(),
targetExtension);
getProbeTestTransform().incrementTransformerCount();
File sourceFile = createSourceFile(request, sourceMultipartFile);
File targetFile = createTargetFile(request, targetFilename);
// Both files are deleted by TransformInterceptor.afterCompletion
final String options = OptionsBuilder
.builder()
.withStartPage(startPage)
.withEndPage(endPage)
.withAlphaRemove(alphaRemove)
.withAutoOrient(autoOrient)
.withCropGravity(cropGravity)
.withCropWidth(cropWidth)
.withCropHeight(cropHeight)
.withCropPercentage(cropPercentage)
.withCropXOffset(cropXOffset)
.withCropYOffset(cropYOffset)
.withThumbnail(thumbnail)
.withResizeWidth(resizeWidth)
.withResizeHeight(resizeHeight)
.withResizePercentage(resizePercentage)
.withAllowEnlargement(allowEnlargement)
.withMaintainAspectRatio(maintainAspectRatio)
.withCommandOptions(commandOptions)
.build();
String pageRange = calculatePageRange(startPage, endPage);
commandExecutor.run(options, sourceFile, pageRange, targetFile,
timeout);
final ResponseEntity<Resource> body = createAttachment(targetFilename, targetFile);
LogEntry.setTargetSize(targetFile.length());
long time = LogEntry.setStatusCodeAndMessage(OK.value(), "Success");
time += LogEntry.addDelay(testDelay);
getProbeTestTransform().recordTransformTime(time);
return body;
}
@Override
public void processTransform(final File sourceFile, final File targetFile,
final String sourceMimetype, final String targetMimetype,
final Map<String, String> transformOptions, final Long timeout)
{
logger.debug("Processing request with: sourceFile '{}', targetFile '{}', transformOptions" +
" '{}', timeout {} ms", sourceFile, targetFile, transformOptions, timeout);
final String options = OptionsBuilder
.builder()
.withStartPage(transformOptions.get("startPage"))
.withEndPage(transformOptions.get("endPage"))
.withAlphaRemove(transformOptions.get("alphaRemove"))
.withAutoOrient(transformOptions.get("autoOrient"))
.withCropGravity(transformOptions.get("cropGravity"))
.withCropWidth(transformOptions.get("cropWidth"))
.withCropHeight(transformOptions.get("cropHeight"))
.withCropPercentage(transformOptions.get("cropPercentage"))
.withCropXOffset(transformOptions.get("cropXOffset"))
.withCropYOffset(transformOptions.get("cropYOffset"))
.withThumbnail(transformOptions.get("thumbnail"))
.withResizeWidth(transformOptions.get("resizeWidth"))
.withResizeHeight(transformOptions.get("resizeHeight"))
.withResizePercentage(transformOptions.get("resizePercentage"))
.withAllowEnlargement(transformOptions.get("allowEnlargement"))
.withMaintainAspectRatio(transformOptions.get("maintainAspectRatio"))
.build();
final String pageRange = calculatePageRange(
stringToInteger(transformOptions.get("startPage")),
stringToInteger(transformOptions.get("endPage")));
commandExecutor.run(options, sourceFile, pageRange, targetFile,
timeout);
}
private static String calculatePageRange(Integer startPage, Integer endPage)
{
return startPage == null
? endPage == null
? ""
: "[" + endPage + ']'
: endPage == null || startPage.equals(endPage)
? "[" + startPage + ']'
: "[" + startPage + '-' + endPage + ']';
}
}

View File

@@ -0,0 +1,361 @@
/*
* #%L
* Alfresco Transform Core
* %%
* Copyright (C) 2005 - 2019 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* -
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* -
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.transformer;
import static org.alfresco.transformer.util.Util.stringToBoolean;
import static org.alfresco.transformer.util.Util.stringToInteger;
import static org.springframework.http.HttpStatus.BAD_REQUEST;
import java.util.List;
import java.util.StringJoiner;
import org.alfresco.transform.exceptions.TransformException;
import com.google.common.collect.ImmutableList;
/**
* ImageMagick options builder.
*
* @author Cezar Leahu
*/
final class OptionsBuilder
{
private static final List<String> GRAVITY_VALUES = ImmutableList.of("North", "NorthEast",
"East", "SouthEast", "South", "SouthWest", "West", "NorthWest", "Center");
private Integer startPage;
private Integer endPage;
private Boolean alphaRemove;
private Boolean autoOrient;
private String cropGravity;
private Integer cropWidth;
private Integer cropHeight;
private Boolean cropPercentage;
private Integer cropXOffset;
private Integer cropYOffset;
private Boolean thumbnail;
private Integer resizeWidth;
private Integer resizeHeight;
private Boolean resizePercentage;
private Boolean allowEnlargement;
private Boolean maintainAspectRatio;
private String commandOptions;
private OptionsBuilder() {}
public OptionsBuilder withStartPage(final String startPage)
{
return withStartPage(stringToInteger(startPage));
}
public OptionsBuilder withStartPage(final Integer startPage)
{
this.startPage = startPage;
return this;
}
public OptionsBuilder withEndPage(final String endPage)
{
return withEndPage(stringToInteger(endPage));
}
public OptionsBuilder withEndPage(final Integer endPage)
{
this.endPage = endPage;
return this;
}
public OptionsBuilder withAlphaRemove(final String alphaRemove)
{
return withAlphaRemove(stringToBoolean(alphaRemove));
}
public OptionsBuilder withAlphaRemove(final Boolean alphaRemove)
{
this.alphaRemove = alphaRemove;
return this;
}
public OptionsBuilder withAutoOrient(final String autoOrient)
{
return withAutoOrient(stringToBoolean(autoOrient));
}
public OptionsBuilder withAutoOrient(final Boolean autoOrient)
{
this.autoOrient = autoOrient;
return this;
}
public OptionsBuilder withCropGravity(final String cropGravity)
{
this.cropGravity = cropGravity;
return this;
}
public OptionsBuilder withCropWidth(final String cropWidth)
{
return withCropWidth(stringToInteger(cropWidth));
}
public OptionsBuilder withCropWidth(final Integer cropWidth)
{
this.cropWidth = cropWidth;
return this;
}
public OptionsBuilder withCropHeight(final String cropHeight)
{
return withCropHeight(stringToInteger(cropHeight));
}
public OptionsBuilder withCropHeight(final Integer cropHeight)
{
this.cropHeight = cropHeight;
return this;
}
public OptionsBuilder withCropPercentage(final String cropPercentage)
{
return withCropPercentage(stringToBoolean(cropPercentage));
}
public OptionsBuilder withCropPercentage(final Boolean cropPercentage)
{
this.cropPercentage = cropPercentage;
return this;
}
public OptionsBuilder withCropXOffset(final String cropXOffset)
{
return withCropXOffset(stringToInteger(cropXOffset));
}
public OptionsBuilder withCropXOffset(final Integer cropXOffset)
{
this.cropXOffset = cropXOffset;
return this;
}
public OptionsBuilder withCropYOffset(final String cropYOffset)
{
return withCropYOffset(stringToInteger(cropYOffset));
}
public OptionsBuilder withCropYOffset(final Integer cropYOffset)
{
this.cropYOffset = cropYOffset;
return this;
}
public OptionsBuilder withThumbnail(final String thumbnail)
{
return withThumbnail(stringToBoolean(thumbnail));
}
public OptionsBuilder withThumbnail(final Boolean thumbnail)
{
this.thumbnail = thumbnail;
return this;
}
public OptionsBuilder withResizeWidth(final String resizeWidth)
{
return withResizeWidth(stringToInteger(resizeWidth));
}
public OptionsBuilder withResizeWidth(final Integer resizeWidth)
{
this.resizeWidth = resizeWidth;
return this;
}
public OptionsBuilder withResizeHeight(final String resizeHeight)
{
return withResizeHeight(stringToInteger(resizeHeight));
}
public OptionsBuilder withResizeHeight(final Integer resizeHeight)
{
this.resizeHeight = resizeHeight;
return this;
}
public OptionsBuilder withResizePercentage(final String resizePercentage)
{
return withResizePercentage(stringToBoolean(resizePercentage));
}
public OptionsBuilder withResizePercentage(final Boolean resizePercentage)
{
this.resizePercentage = resizePercentage;
return this;
}
public OptionsBuilder withAllowEnlargement(final String allowEnlargement)
{
return withAllowEnlargement(stringToBoolean(allowEnlargement));
}
public OptionsBuilder withAllowEnlargement(final Boolean allowEnlargement)
{
this.allowEnlargement = allowEnlargement;
return this;
}
public OptionsBuilder withMaintainAspectRatio(final String maintainAspectRatio)
{
return withMaintainAspectRatio(stringToBoolean(maintainAspectRatio));
}
public OptionsBuilder withMaintainAspectRatio(final Boolean maintainAspectRatio)
{
this.maintainAspectRatio = maintainAspectRatio;
return this;
}
public OptionsBuilder withCommandOptions(final String commandOptions)
{
this.commandOptions = commandOptions;
return this;
}
public String build()
{
if (cropGravity != null)
{
cropGravity = cropGravity.trim();
if (cropGravity.isEmpty())
{
cropGravity = null;
}
else if (!GRAVITY_VALUES.contains(cropGravity))
{
throw new TransformException(BAD_REQUEST.value(), "Invalid cropGravity value");
}
}
StringJoiner args = new StringJoiner(" ");
if (alphaRemove != null && alphaRemove)
{
args.add("-alpha");
args.add(("remove"));
}
if (autoOrient != null && autoOrient)
{
args.add("-auto-orient");
}
if (cropGravity != null || cropWidth != null || cropHeight != null || cropPercentage != null ||
cropXOffset != null || cropYOffset != null)
{
if (cropGravity != null)
{
args.add("-gravity");
args.add(cropGravity);
}
StringBuilder crop = new StringBuilder();
if (cropWidth != null && cropWidth >= 0)
{
crop.append(cropWidth);
}
if (cropHeight != null && cropHeight >= 0)
{
crop.append('x');
crop.append(cropHeight);
}
if (cropPercentage != null && cropPercentage)
{
crop.append('%');
}
if (cropXOffset != null)
{
if (cropXOffset >= 0)
{
crop.append('+');
}
crop.append(cropXOffset);
}
if (cropYOffset != null)
{
if (cropYOffset >= 0)
{
crop.append('+');
}
crop.append(cropYOffset);
}
if (crop.length() > 1)
{
args.add("-crop");
args.add(crop);
}
args.add("+repage");
}
if (resizeHeight != null || resizeWidth != null || resizePercentage != null || maintainAspectRatio != null)
{
args.add(thumbnail != null && thumbnail ? "-thumbnail" : "-resize");
StringBuilder resize = new StringBuilder();
if (resizeWidth != null && resizeWidth >= 0)
{
resize.append(resizeWidth);
}
if (resizeHeight != null && resizeHeight >= 0)
{
resize.append('x');
resize.append(resizeHeight);
}
if (resizePercentage != null && resizePercentage)
{
resize.append('%');
}
if (allowEnlargement == null || !allowEnlargement)
{
resize.append('>');
}
if (maintainAspectRatio != null && maintainAspectRatio)
{
resize.append('!');
}
if (resize.length() > 1)
{
args.add(resize);
}
}
return (commandOptions == null || "".equals(
commandOptions.trim()) ? "" : commandOptions + ' ') +
args.toString();
}
public static OptionsBuilder builder()
{
return new OptionsBuilder();
}
}

View File

@@ -0,0 +1,2 @@
queue:
engineRequestQueue: ${TRANSFORM_ENGINE_REQUEST_QUEUE:org.alfresco.transform.engine.imagemagick.acs}

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

View File

@@ -0,0 +1,43 @@
<html xmlns:th="http://www.thymeleaf.org">
<body>
<div>
<h2>ImageMagick Test Transformation</h2>
<form method="POST" enctype="multipart/form-data" action="/transform">
<table>
<tr><td><div style="text-align:right">file *</div></td><td><input type="file" name="file" /></td></tr>
<tr><td><div style="text-align:right">targetExtension *</div></td><td><input type="text" name="targetExtension" value="" /></td></tr>
<tr><td><div style="text-align:right">timeout</div></td><td><input type="text" name="timeout" value="" /></td></tr>
<tr><td><div style="text-align:right">testDelay</div></td><td><input type="text" name="testDelay" value="" /></td></tr>
<tr><td><div style="text-align:right">startPage</div></td><td><input type="text" name="startPage" /></td></tr>
<tr><td><div style="text-align:right">endPage</div></td><td><input type="text" name="endPage" /></td></tr>
<tr><td><div style="text-align:right">alphaRemove</div></td><td><input type="text" name="alphaRemove" /></td></tr>
<tr><td><div style="text-align:right">autoOrient</div></td><td><input type="text" name="autoOrient" /></td></tr>
<tr><td><div style="text-align:right">cropGravity</div></td><td><input type="text" name="cropGravity" />North, NorthEast...Center</td></tr>
<tr><td><div style="text-align:right">cropWidth</div></td><td><input type="text" name="cropWidth" /></td></tr>
<tr><td><div style="text-align:right">cropHeight</div></td><td><input type="text" name="cropHeight" /></td></tr>
<tr><td><div style="text-align:right">cropPercentage</div></td><td><input type="checkbox" name="cropPercentage" value="true" /></td></tr>
<tr><td><div style="text-align:right">cropXOffset</div></td><td><input type="text" name="cropXOffset" /></td></tr>
<tr><td><div style="text-align:right">cropYOffset</div></td><td><input type="text" name="cropYOffset" /></td></tr>
<tr><td><div style="text-align:right">thumbnail</div></td><td><input type="checkbox" name="thumbnail" value="true" /></td></tr>
<tr><td><div style="text-align:right">resizeWidth</div></td><td><input type="text" name="resizeWidth" value="" /></td></tr>
<tr><td><div style="text-align:right">resizeHeight</div></td><td><input type="text" name="resizeHeight" value="" /></td></tr>
<tr><td><div style="text-align:right">resizePercentage</div></td><td><input type="checkbox" name="resizePercentage" value="true" /></td></tr>
<tr><td><div style="text-align:right">allowEnlargement</div></td><td><input type="checkbox" name="allowEnlargement" value="true" /></td></tr>
<tr><td><div style="text-align:right">maintainAspectRatio</div></td><td><input type="checkbox" name="maintainAspectRatio" value="true" /></td></tr>
<tr><td></td><td><input type="submit" value="Transform" /></td></tr>
</table>
</form>
</div>
<div>
<a href="/log">Log entries</a>
</div>
</body>
</html>

View File

@@ -0,0 +1,387 @@
/*
* #%L
* Alfresco Transform Core
* %%
* Copyright (C) 2005 - 2019 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* -
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* -
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.transformer;
import static org.alfresco.transformer.executors.RuntimeExec.ExecutionResult;
import static org.hamcrest.Matchers.containsString;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.Mockito.when;
import static org.springframework.http.HttpHeaders.ACCEPT;
import static org.springframework.http.HttpHeaders.CONTENT_DISPOSITION;
import static org.springframework.http.HttpHeaders.CONTENT_TYPE;
import static org.springframework.http.HttpStatus.BAD_REQUEST;
import static org.springframework.http.HttpStatus.CREATED;
import static org.springframework.http.HttpStatus.OK;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
import static org.springframework.http.MediaType.IMAGE_PNG_VALUE;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.header;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import static org.springframework.util.StringUtils.getFilenameExtension;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.alfresco.transform.client.model.TransformReply;
import org.alfresco.transform.client.model.TransformRequest;
import org.alfresco.transformer.executors.ImageMagickCommandExecutor;
import org.alfresco.transformer.executors.RuntimeExec;
import org.alfresco.transformer.model.FileRefEntity;
import org.alfresco.transformer.model.FileRefResponse;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.stubbing.Answer;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.boot.test.mock.mockito.SpyBean;
import org.springframework.core.io.FileSystemResource;
import org.springframework.core.io.Resource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.ResponseEntity;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.util.ReflectionTestUtils;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
/**
* Test the ImageMagickController without a server.
* Super class includes tests for the AbstractTransformerController.
*/
@RunWith(SpringRunner.class)
@WebMvcTest(ImageMagickController.class)
public class ImageMagickControllerTest extends AbstractTransformerControllerTest
{
@Mock
private ExecutionResult mockExecutionResult;
@Mock
private RuntimeExec mockTransformCommand;
@Mock
private RuntimeExec mockCheckCommand;
private ImageMagickCommandExecutor commandExecutor = new ImageMagickCommandExecutor();
@SpyBean
private ImageMagickController controller;
@Before
public void before() throws IOException
{
ReflectionTestUtils.setField(commandExecutor, "transformCommand", mockTransformCommand);
ReflectionTestUtils.setField(commandExecutor, "checkCommand", mockCheckCommand);
ReflectionTestUtils.setField(controller, "commandExecutor", commandExecutor);
mockTransformCommand("jpg", "png", "image/jpg", true);
}
@Override
protected void mockTransformCommand(String sourceExtension,
String targetExtension, String sourceMimetype,
boolean readTargetFileBytes) throws IOException
{
this.sourceExtension = sourceExtension;
this.targetExtension = targetExtension;
this.sourceMimetype = sourceMimetype;
expectedOptions = null;
expectedSourceSuffix = null;
expectedSourceFileBytes = readTestFile(sourceExtension);
expectedTargetFileBytes = readTargetFileBytes ? readTestFile(targetExtension) : null;
sourceFile = new MockMultipartFile("file", "quick." + sourceExtension, sourceMimetype,
expectedSourceFileBytes);
when(mockTransformCommand.execute(any(), anyLong())).thenAnswer(
(Answer<RuntimeExec.ExecutionResult>) invocation -> {
Map<String, String> actualProperties = invocation.getArgument(0);
assertEquals("There should be 3 properties", 3, actualProperties.size());
String actualOptions = actualProperties.get("options");
String actualSource = actualProperties.get("source");
String actualTarget = actualProperties.get("target");
String actualTargetExtension = getFilenameExtension(actualTarget);
assertNotNull(actualSource);
assertNotNull(actualTarget);
if (expectedSourceSuffix != null)
{
assertTrue(
"The source file \"" + actualSource + "\" should have ended in \"" + expectedSourceSuffix + "\"",
actualSource.endsWith(expectedSourceSuffix));
actualSource = actualSource.substring(0,
actualSource.length() - expectedSourceSuffix.length());
}
assertNotNull(actualOptions);
if (expectedOptions != null)
{
assertEquals("expectedOptions", expectedOptions, actualOptions);
}
Long actualTimeout = invocation.getArgument(1);
assertNotNull(actualTimeout);
if (expectedTimeout != null)
{
assertEquals("expectedTimeout", expectedTimeout, actualTimeout);
}
// Copy a test file into the target file location if it exists
int i = actualTarget.lastIndexOf('_');
if (i >= 0)
{
String testFilename = actualTarget.substring(i + 1);
File testFile = getTestFile(testFilename, false);
File targetFile = new File(actualTarget);
generateTargetFileFromResourceFile(actualTargetExtension, testFile,
targetFile);
}
// Check the supplied source file has not been changed.
byte[] actualSourceFileBytes = Files.readAllBytes(new File(actualSource).toPath());
assertTrue("Source file is not the same",
Arrays.equals(expectedSourceFileBytes, actualSourceFileBytes));
return mockExecutionResult;
});
when(mockExecutionResult.getExitValue()).thenReturn(0);
when(mockExecutionResult.getStdErr()).thenReturn("STDERROR");
when(mockExecutionResult.getStdOut()).thenReturn("STDOUT");
}
@Override
protected AbstractTransformerController getController()
{
return controller;
}
@Test
public void cropGravityGoodTest() throws Exception
{
for (String value : new String[]{"North", "NorthEast", "East", "SouthEast", "South", "SouthWest", "West", "NorthWest", "Center"})
{
expectedOptions = "-gravity " + value + " +repage";
mockMvc
.perform(MockMvcRequestBuilders
.multipart("/transform")
.file(sourceFile)
.param("targetExtension", targetExtension)
.param("cropGravity", value))
.andExpect(status().is(OK.value()))
.andExpect(content().bytes(expectedTargetFileBytes))
.andExpect(header().string("Content-Disposition",
"attachment; filename*= UTF-8''quick." + targetExtension));
}
}
@Test
public void cropGravityBadTest() throws Exception
{
mockMvc
.perform(MockMvcRequestBuilders
.multipart("/transform")
.file(sourceFile)
.param("targetExtension", targetExtension)
.param("cropGravity", "badValue"))
.andExpect(status().is(BAD_REQUEST.value()));
}
@Test
public void optionsTest() throws Exception
{
expectedOptions = "-alpha remove -gravity SouthEast -crop 123x456%+90+12 +repage -thumbnail 321x654%!";
expectedSourceSuffix = "[2-3]";
mockMvc
.perform(MockMvcRequestBuilders
.multipart("/transform")
.file(sourceFile)
.param("targetExtension", targetExtension)
.param("startPage", "2")
.param("endPage", "3")
.param("alphaRemove", "true")
.param("autoOrient", "false")
.param("cropGravity", "SouthEast")
.param("cropWidth", "123")
.param("cropHeight", "456")
.param("cropPercentage", "true")
.param("cropXOffset", "90")
.param("cropYOffset", "12")
.param("thumbnail", "true")
.param("resizeWidth", "321")
.param("resizeHeight", "654")
.param("resizePercentage", "true")
.param("allowEnlargement", "true")
.param("maintainAspectRatio", "true"))
.andExpect(status().is(OK.value()))
.andExpect(content().bytes(expectedTargetFileBytes))
.andExpect(header().string("Content-Disposition",
"attachment; filename*= UTF-8''quick." + targetExtension));
}
@Test
public void optionsNegateBooleansTest() throws Exception
{
expectedOptions = "-auto-orient -gravity SouthEast -crop 123x456+90+12 +repage -resize 321x654>";
expectedSourceSuffix = "[2-3]";
mockMvc
.perform(MockMvcRequestBuilders
.multipart("/transform")
.file(sourceFile)
.param("targetExtension", targetExtension)
.param("startPage", "2")
.param("endPage", "3")
.param("alphaRemove", "false")
.param("autoOrient", "true")
.param("cropGravity", "SouthEast")
.param("cropWidth", "123")
.param("cropHeight", "456")
.param("cropPercentage", "false")
.param("cropXOffset", "90")
.param("cropYOffset", "12")
.param("thumbnail", "false")
.param("resizeWidth", "321")
.param("resizeHeight", "654")
.param("resizePercentage", "false")
.param("allowEnlargement", "false")
.param("maintainAspectRatio", "false"))
.andExpect(status().is(OK.value()))
.andExpect(content().bytes(expectedTargetFileBytes))
.andExpect(header().string("Content-Disposition",
"attachment; filename*= UTF-8''quick." + targetExtension));
}
@Test
public void deprecatedCommandOptionsTest() throws Exception
{
// Example of why the commandOptions parameter is a bad idea.
expectedOptions = "( horrible command / ); -resize 321x654>";
mockMvc
.perform(MockMvcRequestBuilders
.multipart("/transform")
.file(sourceFile)
.param("targetExtension", targetExtension)
.param("thumbnail", "false")
.param("resizeWidth", "321")
.param("resizeHeight", "654")
.param("commandOptions", "( horrible command / );"))
.andExpect(status().is(OK.value()))
.andExpect(content().bytes(expectedTargetFileBytes))
.andExpect(header().string("Content-Disposition",
"attachment; filename*= UTF-8''quick." + targetExtension));
}
@Override
protected void updateTransformRequestWithSpecificOptions(TransformRequest transformRequest)
{
transformRequest.setSourceExtension("png");
transformRequest.setTargetExtension("png");
transformRequest.setSourceMediaType(IMAGE_PNG_VALUE);
transformRequest.setTargetMediaType(IMAGE_PNG_VALUE);
}
@Test
public void badExitCodeTest() throws Exception
{
when(mockExecutionResult.getExitValue()).thenReturn(1);
mockMvc.perform(mockMvcRequest("/transform", sourceFile, "targetExtension", "xxx"))
.andExpect(status().is(BAD_REQUEST.value()))
.andExpect(
status().reason(containsString("Transformer exit code was not 0: \nSTDERR")));
}
@Test
public void testPojoTransform() throws Exception
{
// Files
String sourceFileRef = UUID.randomUUID().toString();
File sourceFile = getTestFile("quick." + sourceExtension, true);
String targetFileRef = UUID.randomUUID().toString();
// Transformation Request POJO
TransformRequest transformRequest = new TransformRequest();
transformRequest.setRequestId("1");
transformRequest.setSchema(1);
transformRequest.setClientData("Alfresco Digital Business Platform");
transformRequest.setTransformRequestOptions(new HashMap<>());
transformRequest.setSourceReference(sourceFileRef);
transformRequest.setSourceExtension(sourceExtension);
transformRequest.setSourceSize(sourceFile.length());
transformRequest.setTargetExtension(targetExtension);
// HTTP Request
HttpHeaders headers = new HttpHeaders();
headers.set(CONTENT_DISPOSITION, "attachment; filename=quick." + sourceExtension);
ResponseEntity<Resource> response = new ResponseEntity<>(new FileSystemResource(
sourceFile), headers, OK);
when(alfrescoSharedFileStoreClient.retrieveFile(sourceFileRef)).thenReturn(response);
when(alfrescoSharedFileStoreClient.saveFile(any()))
.thenReturn(new FileRefResponse(new FileRefEntity(targetFileRef)));
when(mockExecutionResult.getExitValue()).thenReturn(0);
// Update the Transformation Request with any specific params before sending it
updateTransformRequestWithSpecificOptions(transformRequest);
// Serialize and call the transformer
String tr = objectMapper.writeValueAsString(transformRequest);
String transformationReplyAsString = mockMvc
.perform(MockMvcRequestBuilders
.post("/transform")
.header(ACCEPT, APPLICATION_JSON_VALUE)
.header(CONTENT_TYPE, APPLICATION_JSON_VALUE)
.content(tr))
.andExpect(status().is(CREATED.value()))
.andReturn().getResponse().getContentAsString();
TransformReply transformReply = objectMapper.readValue(transformationReplyAsString,
TransformReply.class);
// Assert the reply
assertEquals(transformRequest.getRequestId(), transformReply.getRequestId());
assertEquals(transformRequest.getClientData(), transformReply.getClientData());
assertEquals(transformRequest.getSchema(), transformReply.getSchema());
}
}

View File

@@ -0,0 +1,52 @@
/*
* #%L
* Alfresco Transform Core
* %%
* Copyright (C) 2005 - 2019 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* -
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* -
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.transformer;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.test.context.junit4.SpringRunner;
/**
* Tests ImageMagickController with a server test harness.
*/
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
public class ImageMagickHttpRequestTest extends AbstractHttpRequestTest
{
@Override
protected String getTransformerName()
{
return "ImageMagick";
}
@Override
protected String getSourceExtension()
{
return "jpg";
}
}

View File

@@ -0,0 +1,63 @@
/*
* #%L
* Alfresco Transform Core
* %%
* Copyright (C) 2005 - 2019 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* -
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* -
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.transformer;
import static org.alfresco.transform.client.model.Mimetype.MIMETYPE_IMAGE_JPEG;
import static org.alfresco.transform.client.model.Mimetype.MIMETYPE_IMAGE_PNG;
import java.util.UUID;
import org.alfresco.transform.client.model.TransformRequest;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
/**
* @author Lucian Tuca
* created on 15/01/2019
*/
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
properties = {"activemq.url=nio://localhost:61616"})
public class ImageMagickQueueTransformServiceIT extends AbstractQueueTransformServiceIT
{
@Override
protected TransformRequest buildRequest()
{
return TransformRequest
.builder()
.withRequestId(UUID.randomUUID().toString())
.withSourceMediaType(MIMETYPE_IMAGE_PNG)
.withTargetMediaType(MIMETYPE_IMAGE_JPEG)
.withTargetExtension("jpeg")
.withSchema(1)
.withClientData("ACS")
.withSourceReference(UUID.randomUUID().toString())
.withSourceSize(32L)
.build();
}
}

View File

@@ -0,0 +1,122 @@
/*
* #%L
* Alfresco Transform Core
* %%
* Copyright (C) 2005 - 2019 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* -
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* -
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.transformer;
import static java.text.MessageFormat.format;
import static java.util.function.Function.identity;
import static java.util.stream.Collectors.toSet;
import static org.alfresco.transformer.EngineClient.sendTRequest;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import static org.springframework.http.HttpStatus.OK;
import java.util.List;
import java.util.Set;
import java.util.stream.Stream;
import org.apache.commons.lang3.tuple.Pair;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.io.Resource;
import org.springframework.http.ResponseEntity;
import com.google.common.collect.ImmutableList;
/**
* @author Cezar Leahu
*/
@RunWith(Parameterized.class)
public class ImageMagickTransformationIT
{
private static final Logger logger = LoggerFactory.getLogger(ImageMagickTransformationIT.class);
private static final String ENGINE_URL = "http://localhost:8090";
private static final List<String> targetMimetypes = ImmutableList.of(
"3fr", "arw", "bmp", "cgm",
"cr2", "dng", "eps", "gif", "ief", "jp2", "jpg",
"k25", "mrw", "nef", "orf", "pbm", "pef", "pgm", "png", "pnm", "ppj", "ppm",
"psd", "r3d", "raf", "ras", "rw2", "rwl", "tiff", "x3f", "xbm", "xpm", "xwd");
private final String sourceFile;
private final String targetExtension;
public ImageMagickTransformationIT(final Pair<String, String> entry)
{
sourceFile = entry.getLeft();
targetExtension = entry.getLeft();
}
@Parameterized.Parameters
public static Set<Pair<String, String>> engineTransformations()
{
return Stream
.of(
allTargets("quick.bmp"),
allTargets("quick.eps"),
allTargets("quick.gif"),
allTargets("quick.jpg"),
allTargets("quick.pbm"),
allTargets("quick.pgm"),
allTargets("quick.png"),
allTargets("quick.pnm"),
allTargets("quick.ppm"),
//allTargets("quick.psd"),
//allTargets("quick.tiff"),
allTargets("quick.xbm"),
allTargets("quick.xpm"),
allTargets("quick.xwd")
)
.flatMap(identity())
.collect(toSet());
}
@Test
public void testTransformation()
{
final String descriptor = format("Transform ({0} -> {1})", sourceFile, null,
targetExtension);
try
{
final ResponseEntity<Resource> response = sendTRequest(ENGINE_URL, sourceFile, null,
null, targetExtension);
assertEquals(descriptor, OK, response.getStatusCode());
}
catch (Exception e)
{
fail(descriptor + " exception: " + e.getMessage());
}
}
private static Stream<Pair<String, String>> allTargets(final String sourceFile)
{
return targetMimetypes
.stream()
.map(k -> Pair.of(sourceFile, k));
}
}

View File

@@ -0,0 +1,22 @@
{
"transformOptions": {
"engineXOptions": [
{"value": {"name": "page"}},
{"value": {"name": "width"}},
{"group": {"transformOptions": [
{"value": {"name": "cropGravity"}}
]}}
]
},
"transformers": [
{
"transformerName": "engineX",
"supportedSourceAndTargetList": [
{"sourceMediaType": "application/pdf", "targetMediaType": "image/png" }
],
"transformOptions": [
"engineXOptions"
]
}
]
}

View File

@@ -0,0 +1,10 @@
{
"transformOptions": {},
"transformers": [
{
"supportedSourceAndTargetList": [
{"sourceMediaType": "application/pdf", "targetMediaType": "image/png" }
]
}
]
}

View File

@@ -0,0 +1,10 @@
{
"transformers": [
{
"transformerName": "engineX",
"supportedSourceAndTargetList": [
{"sourceMediaType": "application/pdf", "targetMediaType": "image/png" }
]
}
]
}

View File

@@ -0,0 +1,26 @@
{
"transformOptions": {
"engineXOptions": [
{"value": {"name": "page"}},
{"value": {"name": "page"}},
{"value": {"name": "width"}},
{"group": {"transformOptions": [
{"value": {"name": "cropGravity"}}
]}}
]
},
"transformers": [
{
"transformerName": "engineX",
"supportedSourceAndTargetList": [
{"sourceMediaType": "application/pdf", "targetMediaType": "image/png" },
{"sourceMediaType": "application/pdf", "targetMediaType": "image/png" },
{"sourceMediaType": "application/pdf", "targetMediaType": "image/png" }
],
"transformOptions": [
"engineXOptions",
"engineXOptions"
]
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 297 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,201 @@
/* XPM */
static char * D:\NewQuickImages\quick_xpm[] = {
"800 190 8 1",
" c None",
". c #FFFFFF",
"+ c #000000",
"@ c #FF0000",
"# c #0000FF",
"$ c #00FF00",
"% c #FFFF00",
"& c #00FFFF",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
"...............................++.......................................................................++.................++.....................................................................++++................................................................................................................................................................++..............................++....................................................++..................................................................................................................................................................................................................................................................................................................................................................",
".................++++++++++++..++.......................................................++..............++.................++....................................................................+++++.................................++.............................................................................................................................++..............................++....................................................++..................................................................................................................................................................................................................................................................................................................................................................",
".................++++++++++++..++.......................................................++..............++.................++...................................................................+++....................................++.....................................................................................................................++......++..............................++....................................................++..................................................................................................................................................................................................................................................................................................................................................................",
"......................++.......++.......................................................................++.................++...................................................................++............................................................................................................................................................++......++..............................++....................................................++..................................................................................................................................................................................................................................................................................................................................................................",
"......................++.......++.......................................................................++.................++...................................................................++............................................................................................................................................................++......++..............................++....................................................++..................................................................................................................................................................................................................................................................................................................................................................",
"......................++.......++.++++........+++++.............+++++++....++.....++....++......++++....++.....++..........++.++++.....++..+++....++++.....++....++....++...++.++++............++++++....++++.....+++....+++.........++++....++.....++....++.++++...++++.....++.++++......+++++.............++++.....++......++.....+++++.....++..+++........+++++++..++.++++........+++++............++....++++++.....+++++++++..++......++...........+++++++......++++.......+++++++..........................................................................................................................................................................................................................................................................................................................................",
"......................++.......++++++++.....++++++++...........++++++++....++.....++....++....+++++++...++....++...........++++++++....+++++++..++++++++...++....++....++...++++++++...........++++++..++++++++....++....++..........++++....++.....++....++++++++.++++++....++++++++....+++++++..........++++++++....++....++....++++++++....+++++++........+++++++..++++++++.....++++++++...........++....+++++++....+++++++++...++....++...........++++++++....++++++++....++++++++..........................................................................................................................................................................................................................................................................................................................................",
"......................++.......+++...+++....++....+++..........++....++....++.....++....++....++....+...++...++............+++...+++...+++......++....++....++...+++..++....+++...+++...........++.....++....++.....++..++.............++....++.....++....+++...++++...+++...+++...+++..++.....+..........++....++....++....++....++....+++...+++.............++......+++...+++....++....+++..........++.........+++.........+++...++....++...........++....++....++....++....++....++..........................................................................................................................................................................................................................................................................................................................................",
"......................++.......++.....++...++......++.........++.....++....++.....++....++...++.........++..++.............++.....++...++......++......++...++..++++..++....++.....++...........++....++......++.....++++..............++....++.....++....++.....++.....++...++.....++..++...............++......++...++....++...++......++...++..............++......++.....++...++......++..........++..........++........+++....++....++..........++.....++...++......++..++.....++..........................................................................................................................................................................................................................................................................................................................................",
"......................++.......++.....++...++++++++++.........++.....++....++.....++....++...++.........++.++..............++.....++...++......++......++...++..+..+..++....++.....++...........++....++......++.....++++..............++....++.....++....++.....++.....++...++.....++..++++.............++......++....++..++....++++++++++...++..............++......++.....++...++++++++++..........++......++++++.......+++......++..++...........++.....++...++......++..++.....++..........................................................................................................................................................................................................................................................................................................................................",
"......................++.......++.....++...++++++++++.........++.....++....++.....++....++...++.........+++++..............++.....++...++......++......++...++..+..+..++....++.....++...........++....++......++......++...............++....++.....++....++.....++.....++...++.....++...++++++..........++......++....++..++....++++++++++...++..............++......++.....++...++++++++++..........++....++++++++......+++.......++..++...........++.....++...++......++..++.....++..........................................................................................................................................................................................................................................................................................................................................",
"......................++.......++.....++...++.................++.....++....++.....++....++...++.........++++++.............++.....++...++......++......++....+.++..++.+.....++.....++...........++....++......++.....++++..............++....++.....++....++.....++.....++...++.....++......++++.........++......++....++..++....++...........++..............++......++.....++...++..................++...+++....++.....+++.........+..+............++.....++...++......++..++.....++..........................................................................................................................................................................................................................................................................................................................................",
"......................++.......++.....++...++.................++.....++....++.....++....++...++.........++..+++............++.....++...++......++......++....+++....+.+.....++.....++...........++....++......++.....++++..............++....++.....++....++.....++.....++...++.....++........++.........++......++.....++++.....++...........++..............++......++.....++...++..................++...++.....++....+++..........++++............++.....++...++......++..++.....++..........................................................................................................................................................................................................................................................................................................................................",
"......................++.......++.....++....+++.....+.........+++...+++....+++...+++....++....++....+...++...+++...........++....++....++.......++....++.....+++....+++.....++.....++...........++.....++....++.....++..++.............++....+++...+++....++.....++.....++...++....++...+.....++..........++....++......++++......+++.....+...++..............++......++.....++....+++.....+..........++...++....+++...+++...........++++............+++...+++....++....++...+++...+++....++....................................................................................................................................................................................................................................................................................................................................",
"......................++.......++.....++....+++++++++..........++++++++.....++++++++....++....+++++++...++....+++..........++++++++....++.......++++++++.....+++....+++.....++.....++...........++.....++++++++....++....++............++.....++++++++....++.....++.....++...++++++++...+++++++...........++++++++.......++.......+++++++++...++..............++++++..++.....++....+++++++++..........++...+++++++++...+++++++++......++..............++++++++....++++++++....++++++++....++....................................................................................................................................................................................................................................................................................................................................",
"......................++.......++.....++......++++++............++++.++......++++.++....++.....+++++....++.....+++.........++.++++.....++.........++++........++.....+......++.....++...........++.......++++.....+++....+++...........++......++++.++....++.....++.....++...+++++++.....+++++..............++++.........++.........++++++....++...............+++++..++.....++......++++++...........++....+++++.++...+++++++++......++...............++++.++......++++.......++++.++....++....................................................................................................................................................................................................................................................................................................................................",
".....................................................................++................................................................................................................................................................++....................................++.......................................................................................................................................................+.............................................++..........................................................................................................................................................................................................................................................................................................................................",
".....................................................................++...............................................................................................................................................................+++....................................++......................................................................................................................................................++............................................+++..........................................................................................................................................................................................................................................................................................................................................",
".....................................................................++............................................................................................................................................................+++++.....................................++......................................................................................................................................................++.......................................+++++++...........................................................................................................................................................................................................................................................................................................................................",
".....................................................................++............................................................................................................................................................++++......................................++.....................................................................................................................................................++........................................++++++............................................................................................................................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
".......................................................................................@@.......................................................................@@.................@@.....................................................................@@@@................................................................................................................................................................@@..............................@@....................................................@@..........................................................................................................................................................................................................................................................................................................",
".........................................................................@@@@@@@@@@@@..@@.......................................................@@..............@@.................@@....................................................................@@@@@.................................@@.............................................................................................................................@@..............................@@....................................................@@..........................................................................................................................................................................................................................................................................................................",
".........................................................................@@@@@@@@@@@@..@@.......................................................@@..............@@.................@@...................................................................@@@....................................@@.....................................................................................................................@@......@@..............................@@....................................................@@..........................................................................................................................................................................................................................................................................................................",
"..............................................................................@@.......@@.......................................................................@@.................@@...................................................................@@............................................................................................................................................................@@......@@..............................@@....................................................@@..........................................................................................................................................................................................................................................................................................................",
"..............................................................................@@.......@@.......................................................................@@.................@@...................................................................@@............................................................................................................................................................@@......@@..............................@@....................................................@@..........................................................................................................................................................................................................................................................................................................",
"..............................................................................@@.......@@.@@@@........@@@@@.............@@@@@@@....@@.....@@....@@......@@@@....@@.....@@..........@@.@@@@.....@@..@@@....@@@@.....@@....@@....@@...@@.@@@@............@@@@@@....@@@@.....@@@....@@@.........@@@@....@@.....@@....@@.@@@@...@@@@.....@@.@@@@......@@@@@.............@@@@.....@@......@@.....@@@@@.....@@..@@@........@@@@@@@..@@.@@@@........@@@@@............@@....@@@@@@.....@@@@@@@@@..@@......@@...........@@@@@@@......@@@@.......@@@@@@@..................................................................................................................................................................................................................................................................................",
"..............................................................................@@.......@@@@@@@@.....@@@@@@@@...........@@@@@@@@....@@.....@@....@@....@@@@@@@...@@....@@...........@@@@@@@@....@@@@@@@..@@@@@@@@...@@....@@....@@...@@@@@@@@...........@@@@@@..@@@@@@@@....@@....@@..........@@@@....@@.....@@....@@@@@@@@.@@@@@@....@@@@@@@@....@@@@@@@..........@@@@@@@@....@@....@@....@@@@@@@@....@@@@@@@........@@@@@@@..@@@@@@@@.....@@@@@@@@...........@@....@@@@@@@....@@@@@@@@@...@@....@@...........@@@@@@@@....@@@@@@@@....@@@@@@@@..................................................................................................................................................................................................................................................................................",
"..............................................................................@@.......@@@...@@@....@@....@@@..........@@....@@....@@.....@@....@@....@@....@...@@...@@............@@@...@@@...@@@......@@....@@....@@...@@@..@@....@@@...@@@...........@@.....@@....@@.....@@..@@.............@@....@@.....@@....@@@...@@@@...@@@...@@@...@@@..@@.....@..........@@....@@....@@....@@....@@....@@@...@@@.............@@......@@@...@@@....@@....@@@..........@@.........@@@.........@@@...@@....@@...........@@....@@....@@....@@....@@....@@..................................................................................................................................................................................................................................................................................",
"..............................................................................@@.......@@.....@@...@@......@@.........@@.....@@....@@.....@@....@@...@@.........@@..@@.............@@.....@@...@@......@@......@@...@@..@@@@..@@....@@.....@@...........@@....@@......@@.....@@@@..............@@....@@.....@@....@@.....@@.....@@...@@.....@@..@@...............@@......@@...@@....@@...@@......@@...@@..............@@......@@.....@@...@@......@@..........@@..........@@........@@@....@@....@@..........@@.....@@...@@......@@..@@.....@@..................................................................................................................................................................................................................................................................................",
"..............................................................................@@.......@@.....@@...@@@@@@@@@@.........@@.....@@....@@.....@@....@@...@@.........@@.@@..............@@.....@@...@@......@@......@@...@@..@..@..@@....@@.....@@...........@@....@@......@@.....@@@@..............@@....@@.....@@....@@.....@@.....@@...@@.....@@..@@@@.............@@......@@....@@..@@....@@@@@@@@@@...@@..............@@......@@.....@@...@@@@@@@@@@..........@@......@@@@@@.......@@@......@@..@@...........@@.....@@...@@......@@..@@.....@@..................................................................................................................................................................................................................................................................................",
"..............................................................................@@.......@@.....@@...@@@@@@@@@@.........@@.....@@....@@.....@@....@@...@@.........@@@@@..............@@.....@@...@@......@@......@@...@@..@..@..@@....@@.....@@...........@@....@@......@@......@@...............@@....@@.....@@....@@.....@@.....@@...@@.....@@...@@@@@@..........@@......@@....@@..@@....@@@@@@@@@@...@@..............@@......@@.....@@...@@@@@@@@@@..........@@....@@@@@@@@......@@@.......@@..@@...........@@.....@@...@@......@@..@@.....@@..................................................................................................................................................................................................................................................................................",
"..............................................................................@@.......@@.....@@...@@.................@@.....@@....@@.....@@....@@...@@.........@@@@@@.............@@.....@@...@@......@@......@@....@.@@..@@.@.....@@.....@@...........@@....@@......@@.....@@@@..............@@....@@.....@@....@@.....@@.....@@...@@.....@@......@@@@.........@@......@@....@@..@@....@@...........@@..............@@......@@.....@@...@@..................@@...@@@....@@.....@@@.........@..@............@@.....@@...@@......@@..@@.....@@..................................................................................................................................................................................................................................................................................",
"..............................................................................@@.......@@.....@@...@@.................@@.....@@....@@.....@@....@@...@@.........@@..@@@............@@.....@@...@@......@@......@@....@@@....@.@.....@@.....@@...........@@....@@......@@.....@@@@..............@@....@@.....@@....@@.....@@.....@@...@@.....@@........@@.........@@......@@.....@@@@.....@@...........@@..............@@......@@.....@@...@@..................@@...@@.....@@....@@@..........@@@@............@@.....@@...@@......@@..@@.....@@..................................................................................................................................................................................................................................................................................",
"..............................................................................@@.......@@.....@@....@@@.....@.........@@@...@@@....@@@...@@@....@@....@@....@...@@...@@@...........@@....@@....@@.......@@....@@.....@@@....@@@.....@@.....@@...........@@.....@@....@@.....@@..@@.............@@....@@@...@@@....@@.....@@.....@@...@@....@@...@.....@@..........@@....@@......@@@@......@@@.....@...@@..............@@......@@.....@@....@@@.....@..........@@...@@....@@@...@@@...........@@@@............@@@...@@@....@@....@@...@@@...@@@....@@............................................................................................................................................................................................................................................................................",
"..............................................................................@@.......@@.....@@....@@@@@@@@@..........@@@@@@@@.....@@@@@@@@....@@....@@@@@@@...@@....@@@..........@@@@@@@@....@@.......@@@@@@@@.....@@@....@@@.....@@.....@@...........@@.....@@@@@@@@....@@....@@............@@.....@@@@@@@@....@@.....@@.....@@...@@@@@@@@...@@@@@@@...........@@@@@@@@.......@@.......@@@@@@@@@...@@..............@@@@@@..@@.....@@....@@@@@@@@@..........@@...@@@@@@@@@...@@@@@@@@@......@@..............@@@@@@@@....@@@@@@@@....@@@@@@@@....@@............................................................................................................................................................................................................................................................................",
"..............................................................................@@.......@@.....@@......@@@@@@............@@@@.@@......@@@@.@@....@@.....@@@@@....@@.....@@@.........@@.@@@@.....@@.........@@@@........@@.....@......@@.....@@...........@@.......@@@@.....@@@....@@@...........@@......@@@@.@@....@@.....@@.....@@...@@@@@@@.....@@@@@..............@@@@.........@@.........@@@@@@....@@...............@@@@@..@@.....@@......@@@@@@...........@@....@@@@@.@@...@@@@@@@@@......@@...............@@@@.@@......@@@@.......@@@@.@@....@@............................................................................................................................................................................................................................................................................",
".............................................................................................................................@@................................................................................................................................................................@@....................................@@.......................................................................................................................................................@.............................................@@..................................................................................................................................................................................................................................................................................",
".............................................................................................................................@@...............................................................................................................................................................@@@....................................@@......................................................................................................................................................@@............................................@@@..................................................................................................................................................................................................................................................................................",
".............................................................................................................................@@............................................................................................................................................................@@@@@.....................................@@......................................................................................................................................................@@.......................................@@@@@@@...................................................................................................................................................................................................................................................................................",
".............................................................................................................................@@............................................................................................................................................................@@@@......................................@@.....................................................................................................................................................@@........................................@@@@@@....................................................................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
"...............................................................................................................................................##.......................................................................##.................##.....................................................................####................................................................................................................................................................##..............................##....................................................##..................................................................................................................................................................................................................................................",
".................................................................................................................................############..##.......................................................##..............##.................##....................................................................#####.................................##.............................................................................................................................##..............................##....................................................##..................................................................................................................................................................................................................................................",
".................................................................................................................................############..##.......................................................##..............##.................##...................................................................###....................................##.....................................................................................................................##......##..............................##....................................................##..................................................................................................................................................................................................................................................",
"......................................................................................................................................##.......##.......................................................................##.................##...................................................................##............................................................................................................................................................##......##..............................##....................................................##..................................................................................................................................................................................................................................................",
"......................................................................................................................................##.......##.......................................................................##.................##...................................................................##............................................................................................................................................................##......##..............................##....................................................##..................................................................................................................................................................................................................................................",
"......................................................................................................................................##.......##.####........#####.............#######....##.....##....##......####....##.....##..........##.####.....##..###....####.....##....##....##...##.####............######....####.....###....###.........####....##.....##....##.####...####.....##.####......#####.............####.....##......##.....#####.....##..###........#######..##.####........#####............##....######.....#########..##......##...........#######......####.......#######..........................................................................................................................................................................................................................",
"......................................................................................................................................##.......########.....########...........########....##.....##....##....#######...##....##...........########....#######..########...##....##....##...########...........######..########....##....##..........####....##.....##....########.######....########....#######..........########....##....##....########....#######........#######..########.....########...........##....#######....#########...##....##...........########....########....########..........................................................................................................................................................................................................................",
"......................................................................................................................................##.......###...###....##....###..........##....##....##.....##....##....##....#...##...##............###...###...###......##....##....##...###..##....###...###...........##.....##....##.....##..##.............##....##.....##....###...####...###...###...###..##.....#..........##....##....##....##....##....###...###.............##......###...###....##....###..........##.........###.........###...##....##...........##....##....##....##....##....##..........................................................................................................................................................................................................................",
"......................................................................................................................................##.......##.....##...##......##.........##.....##....##.....##....##...##.........##..##.............##.....##...##......##......##...##..####..##....##.....##...........##....##......##.....####..............##....##.....##....##.....##.....##...##.....##..##...............##......##...##....##...##......##...##..............##......##.....##...##......##..........##..........##........###....##....##..........##.....##...##......##..##.....##..........................................................................................................................................................................................................................",
"......................................................................................................................................##.......##.....##...##########.........##.....##....##.....##....##...##.........##.##..............##.....##...##......##......##...##..#..#..##....##.....##...........##....##......##.....####..............##....##.....##....##.....##.....##...##.....##..####.............##......##....##..##....##########...##..............##......##.....##...##########..........##......######.......###......##..##...........##.....##...##......##..##.....##..........................................................................................................................................................................................................................",
"......................................................................................................................................##.......##.....##...##########.........##.....##....##.....##....##...##.........#####..............##.....##...##......##......##...##..#..#..##....##.....##...........##....##......##......##...............##....##.....##....##.....##.....##...##.....##...######..........##......##....##..##....##########...##..............##......##.....##...##########..........##....########......###.......##..##...........##.....##...##......##..##.....##..........................................................................................................................................................................................................................",
"......................................................................................................................................##.......##.....##...##.................##.....##....##.....##....##...##.........######.............##.....##...##......##......##....#.##..##.#.....##.....##...........##....##......##.....####..............##....##.....##....##.....##.....##...##.....##......####.........##......##....##..##....##...........##..............##......##.....##...##..................##...###....##.....###.........#..#............##.....##...##......##..##.....##..........................................................................................................................................................................................................................",
"......................................................................................................................................##.......##.....##...##.................##.....##....##.....##....##...##.........##..###............##.....##...##......##......##....###....#.#.....##.....##...........##....##......##.....####..............##....##.....##....##.....##.....##...##.....##........##.........##......##.....####.....##...........##..............##......##.....##...##..................##...##.....##....###..........####............##.....##...##......##..##.....##..........................................................................................................................................................................................................................",
"......................................................................................................................................##.......##.....##....###.....#.........###...###....###...###....##....##....#...##...###...........##....##....##.......##....##.....###....###.....##.....##...........##.....##....##.....##..##.............##....###...###....##.....##.....##...##....##...#.....##..........##....##......####......###.....#...##..............##......##.....##....###.....#..........##...##....###...###...........####............###...###....##....##...###...###....##....................................................................................................................................................................................................................",
"......................................................................................................................................##.......##.....##....#########..........########.....########....##....#######...##....###..........########....##.......########.....###....###.....##.....##...........##.....########....##....##............##.....########....##.....##.....##...########...#######...........########.......##.......#########...##..............######..##.....##....#########..........##...#########...#########......##..............########....########....########....##....................................................................................................................................................................................................................",
"......................................................................................................................................##.......##.....##......######............####.##......####.##....##.....#####....##.....###.........##.####.....##.........####........##.....#......##.....##...........##.......####.....###....###...........##......####.##....##.....##.....##...#######.....#####..............####.........##.........######....##...............#####..##.....##......######...........##....#####.##...#########......##...............####.##......####.......####.##....##....................................................................................................................................................................................................................",
".....................................................................................................................................................................................##................................................................................................................................................................##....................................##.......................................................................................................................................................#.............................................##..........................................................................................................................................................................................................................",
".....................................................................................................................................................................................##...............................................................................................................................................................###....................................##......................................................................................................................................................##............................................###..........................................................................................................................................................................................................................",
".....................................................................................................................................................................................##............................................................................................................................................................#####.....................................##......................................................................................................................................................##.......................................#######...........................................................................................................................................................................................................................",
".....................................................................................................................................................................................##............................................................................................................................................................####......................................##.....................................................................................................................................................##........................................######............................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
".......................................................................................................................................................................................................$$.......................................................................$$.................$$.....................................................................$$$$................................................................................................................................................................$$..............................$$....................................................$$..........................................................................................................................................................................................",
".........................................................................................................................................................................................$$$$$$$$$$$$..$$.......................................................$$..............$$.................$$....................................................................$$$$$.................................$$.............................................................................................................................$$..............................$$....................................................$$..........................................................................................................................................................................................",
".........................................................................................................................................................................................$$$$$$$$$$$$..$$.......................................................$$..............$$.................$$...................................................................$$$....................................$$.....................................................................................................................$$......$$..............................$$....................................................$$..........................................................................................................................................................................................",
"..............................................................................................................................................................................................$$.......$$.......................................................................$$.................$$...................................................................$$............................................................................................................................................................$$......$$..............................$$....................................................$$..........................................................................................................................................................................................",
"..............................................................................................................................................................................................$$.......$$.......................................................................$$.................$$...................................................................$$............................................................................................................................................................$$......$$..............................$$....................................................$$..........................................................................................................................................................................................",
"..............................................................................................................................................................................................$$.......$$.$$$$........$$$$$.............$$$$$$$....$$.....$$....$$......$$$$....$$.....$$..........$$.$$$$.....$$..$$$....$$$$.....$$....$$....$$...$$.$$$$............$$$$$$....$$$$.....$$$....$$$.........$$$$....$$.....$$....$$.$$$$...$$$$.....$$.$$$$......$$$$$.............$$$$.....$$......$$.....$$$$$.....$$..$$$........$$$$$$$..$$.$$$$........$$$$$............$$....$$$$$$.....$$$$$$$$$..$$......$$...........$$$$$$$......$$$$.......$$$$$$$..................................................................................................................................................................",
"..............................................................................................................................................................................................$$.......$$$$$$$$.....$$$$$$$$...........$$$$$$$$....$$.....$$....$$....$$$$$$$...$$....$$...........$$$$$$$$....$$$$$$$..$$$$$$$$...$$....$$....$$...$$$$$$$$...........$$$$$$..$$$$$$$$....$$....$$..........$$$$....$$.....$$....$$$$$$$$.$$$$$$....$$$$$$$$....$$$$$$$..........$$$$$$$$....$$....$$....$$$$$$$$....$$$$$$$........$$$$$$$..$$$$$$$$.....$$$$$$$$...........$$....$$$$$$$....$$$$$$$$$...$$....$$...........$$$$$$$$....$$$$$$$$....$$$$$$$$..................................................................................................................................................................",
"..............................................................................................................................................................................................$$.......$$$...$$$....$$....$$$..........$$....$$....$$.....$$....$$....$$....$...$$...$$............$$$...$$$...$$$......$$....$$....$$...$$$..$$....$$$...$$$...........$$.....$$....$$.....$$..$$.............$$....$$.....$$....$$$...$$$$...$$$...$$$...$$$..$$.....$..........$$....$$....$$....$$....$$....$$$...$$$.............$$......$$$...$$$....$$....$$$..........$$.........$$$.........$$$...$$....$$...........$$....$$....$$....$$....$$....$$..................................................................................................................................................................",
"..............................................................................................................................................................................................$$.......$$.....$$...$$......$$.........$$.....$$....$$.....$$....$$...$$.........$$..$$.............$$.....$$...$$......$$......$$...$$..$$$$..$$....$$.....$$...........$$....$$......$$.....$$$$..............$$....$$.....$$....$$.....$$.....$$...$$.....$$..$$...............$$......$$...$$....$$...$$......$$...$$..............$$......$$.....$$...$$......$$..........$$..........$$........$$$....$$....$$..........$$.....$$...$$......$$..$$.....$$..................................................................................................................................................................",
"..............................................................................................................................................................................................$$.......$$.....$$...$$$$$$$$$$.........$$.....$$....$$.....$$....$$...$$.........$$.$$..............$$.....$$...$$......$$......$$...$$..$..$..$$....$$.....$$...........$$....$$......$$.....$$$$..............$$....$$.....$$....$$.....$$.....$$...$$.....$$..$$$$.............$$......$$....$$..$$....$$$$$$$$$$...$$..............$$......$$.....$$...$$$$$$$$$$..........$$......$$$$$$.......$$$......$$..$$...........$$.....$$...$$......$$..$$.....$$..................................................................................................................................................................",
"..............................................................................................................................................................................................$$.......$$.....$$...$$$$$$$$$$.........$$.....$$....$$.....$$....$$...$$.........$$$$$..............$$.....$$...$$......$$......$$...$$..$..$..$$....$$.....$$...........$$....$$......$$......$$...............$$....$$.....$$....$$.....$$.....$$...$$.....$$...$$$$$$..........$$......$$....$$..$$....$$$$$$$$$$...$$..............$$......$$.....$$...$$$$$$$$$$..........$$....$$$$$$$$......$$$.......$$..$$...........$$.....$$...$$......$$..$$.....$$..................................................................................................................................................................",
"..............................................................................................................................................................................................$$.......$$.....$$...$$.................$$.....$$....$$.....$$....$$...$$.........$$$$$$.............$$.....$$...$$......$$......$$....$.$$..$$.$.....$$.....$$...........$$....$$......$$.....$$$$..............$$....$$.....$$....$$.....$$.....$$...$$.....$$......$$$$.........$$......$$....$$..$$....$$...........$$..............$$......$$.....$$...$$..................$$...$$$....$$.....$$$.........$..$............$$.....$$...$$......$$..$$.....$$..................................................................................................................................................................",
"..............................................................................................................................................................................................$$.......$$.....$$...$$.................$$.....$$....$$.....$$....$$...$$.........$$..$$$............$$.....$$...$$......$$......$$....$$$....$.$.....$$.....$$...........$$....$$......$$.....$$$$..............$$....$$.....$$....$$.....$$.....$$...$$.....$$........$$.........$$......$$.....$$$$.....$$...........$$..............$$......$$.....$$...$$..................$$...$$.....$$....$$$..........$$$$............$$.....$$...$$......$$..$$.....$$..................................................................................................................................................................",
"..............................................................................................................................................................................................$$.......$$.....$$....$$$.....$.........$$$...$$$....$$$...$$$....$$....$$....$...$$...$$$...........$$....$$....$$.......$$....$$.....$$$....$$$.....$$.....$$...........$$.....$$....$$.....$$..$$.............$$....$$$...$$$....$$.....$$.....$$...$$....$$...$.....$$..........$$....$$......$$$$......$$$.....$...$$..............$$......$$.....$$....$$$.....$..........$$...$$....$$$...$$$...........$$$$............$$$...$$$....$$....$$...$$$...$$$....$$............................................................................................................................................................",
"..............................................................................................................................................................................................$$.......$$.....$$....$$$$$$$$$..........$$$$$$$$.....$$$$$$$$....$$....$$$$$$$...$$....$$$..........$$$$$$$$....$$.......$$$$$$$$.....$$$....$$$.....$$.....$$...........$$.....$$$$$$$$....$$....$$............$$.....$$$$$$$$....$$.....$$.....$$...$$$$$$$$...$$$$$$$...........$$$$$$$$.......$$.......$$$$$$$$$...$$..............$$$$$$..$$.....$$....$$$$$$$$$..........$$...$$$$$$$$$...$$$$$$$$$......$$..............$$$$$$$$....$$$$$$$$....$$$$$$$$....$$............................................................................................................................................................",
"..............................................................................................................................................................................................$$.......$$.....$$......$$$$$$............$$$$.$$......$$$$.$$....$$.....$$$$$....$$.....$$$.........$$.$$$$.....$$.........$$$$........$$.....$......$$.....$$...........$$.......$$$$.....$$$....$$$...........$$......$$$$.$$....$$.....$$.....$$...$$$$$$$.....$$$$$..............$$$$.........$$.........$$$$$$....$$...............$$$$$..$$.....$$......$$$$$$...........$$....$$$$$.$$...$$$$$$$$$......$$...............$$$$.$$......$$$$.......$$$$.$$....$$............................................................................................................................................................",
".............................................................................................................................................................................................................................................$$................................................................................................................................................................$$....................................$$.......................................................................................................................................................$.............................................$$..................................................................................................................................................................",
".............................................................................................................................................................................................................................................$$...............................................................................................................................................................$$$....................................$$......................................................................................................................................................$$............................................$$$..................................................................................................................................................................",
".............................................................................................................................................................................................................................................$$............................................................................................................................................................$$$$$.....................................$$......................................................................................................................................................$$.......................................$$$$$$$...................................................................................................................................................................",
".............................................................................................................................................................................................................................................$$............................................................................................................................................................$$$$......................................$$.....................................................................................................................................................$$........................................$$$$$$....................................................................................................................................................................",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
"...............................................................................................................................................................................................................................................................%%.......................................................................%%.................%%.....................................................................%%%%................................................................................................................................................................%%..............................%%....................................................%%..................................................................................................................................",
".................................................................................................................................................................................................................................................%%%%%%%%%%%%..%%.......................................................%%..............%%.................%%....................................................................%%%%%.................................%%.............................................................................................................................%%..............................%%....................................................%%..................................................................................................................................",
".................................................................................................................................................................................................................................................%%%%%%%%%%%%..%%.......................................................%%..............%%.................%%...................................................................%%%....................................%%.....................................................................................................................%%......%%..............................%%....................................................%%..................................................................................................................................",
"......................................................................................................................................................................................................................................................%%.......%%.......................................................................%%.................%%...................................................................%%............................................................................................................................................................%%......%%..............................%%....................................................%%..................................................................................................................................",
"......................................................................................................................................................................................................................................................%%.......%%.......................................................................%%.................%%...................................................................%%............................................................................................................................................................%%......%%..............................%%....................................................%%..................................................................................................................................",
"......................................................................................................................................................................................................................................................%%.......%%.%%%%........%%%%%.............%%%%%%%....%%.....%%....%%......%%%%....%%.....%%..........%%.%%%%.....%%..%%%....%%%%.....%%....%%....%%...%%.%%%%............%%%%%%....%%%%.....%%%....%%%.........%%%%....%%.....%%....%%.%%%%...%%%%.....%%.%%%%......%%%%%.............%%%%.....%%......%%.....%%%%%.....%%..%%%........%%%%%%%..%%.%%%%........%%%%%............%%....%%%%%%.....%%%%%%%%%..%%......%%...........%%%%%%%......%%%%.......%%%%%%%..........................................................................................................",
"......................................................................................................................................................................................................................................................%%.......%%%%%%%%.....%%%%%%%%...........%%%%%%%%....%%.....%%....%%....%%%%%%%...%%....%%...........%%%%%%%%....%%%%%%%..%%%%%%%%...%%....%%....%%...%%%%%%%%...........%%%%%%..%%%%%%%%....%%....%%..........%%%%....%%.....%%....%%%%%%%%.%%%%%%....%%%%%%%%....%%%%%%%..........%%%%%%%%....%%....%%....%%%%%%%%....%%%%%%%........%%%%%%%..%%%%%%%%.....%%%%%%%%...........%%....%%%%%%%....%%%%%%%%%...%%....%%...........%%%%%%%%....%%%%%%%%....%%%%%%%%..........................................................................................................",
"......................................................................................................................................................................................................................................................%%.......%%%...%%%....%%....%%%..........%%....%%....%%.....%%....%%....%%....%...%%...%%............%%%...%%%...%%%......%%....%%....%%...%%%..%%....%%%...%%%...........%%.....%%....%%.....%%..%%.............%%....%%.....%%....%%%...%%%%...%%%...%%%...%%%..%%.....%..........%%....%%....%%....%%....%%....%%%...%%%.............%%......%%%...%%%....%%....%%%..........%%.........%%%.........%%%...%%....%%...........%%....%%....%%....%%....%%....%%..........................................................................................................",
"......................................................................................................................................................................................................................................................%%.......%%.....%%...%%......%%.........%%.....%%....%%.....%%....%%...%%.........%%..%%.............%%.....%%...%%......%%......%%...%%..%%%%..%%....%%.....%%...........%%....%%......%%.....%%%%..............%%....%%.....%%....%%.....%%.....%%...%%.....%%..%%...............%%......%%...%%....%%...%%......%%...%%..............%%......%%.....%%...%%......%%..........%%..........%%........%%%....%%....%%..........%%.....%%...%%......%%..%%.....%%..........................................................................................................",
"......................................................................................................................................................................................................................................................%%.......%%.....%%...%%%%%%%%%%.........%%.....%%....%%.....%%....%%...%%.........%%.%%..............%%.....%%...%%......%%......%%...%%..%..%..%%....%%.....%%...........%%....%%......%%.....%%%%..............%%....%%.....%%....%%.....%%.....%%...%%.....%%..%%%%.............%%......%%....%%..%%....%%%%%%%%%%...%%..............%%......%%.....%%...%%%%%%%%%%..........%%......%%%%%%.......%%%......%%..%%...........%%.....%%...%%......%%..%%.....%%..........................................................................................................",
"......................................................................................................................................................................................................................................................%%.......%%.....%%...%%%%%%%%%%.........%%.....%%....%%.....%%....%%...%%.........%%%%%..............%%.....%%...%%......%%......%%...%%..%..%..%%....%%.....%%...........%%....%%......%%......%%...............%%....%%.....%%....%%.....%%.....%%...%%.....%%...%%%%%%..........%%......%%....%%..%%....%%%%%%%%%%...%%..............%%......%%.....%%...%%%%%%%%%%..........%%....%%%%%%%%......%%%.......%%..%%...........%%.....%%...%%......%%..%%.....%%..........................................................................................................",
"......................................................................................................................................................................................................................................................%%.......%%.....%%...%%.................%%.....%%....%%.....%%....%%...%%.........%%%%%%.............%%.....%%...%%......%%......%%....%.%%..%%.%.....%%.....%%...........%%....%%......%%.....%%%%..............%%....%%.....%%....%%.....%%.....%%...%%.....%%......%%%%.........%%......%%....%%..%%....%%...........%%..............%%......%%.....%%...%%..................%%...%%%....%%.....%%%.........%..%............%%.....%%...%%......%%..%%.....%%..........................................................................................................",
"......................................................................................................................................................................................................................................................%%.......%%.....%%...%%.................%%.....%%....%%.....%%....%%...%%.........%%..%%%............%%.....%%...%%......%%......%%....%%%....%.%.....%%.....%%...........%%....%%......%%.....%%%%..............%%....%%.....%%....%%.....%%.....%%...%%.....%%........%%.........%%......%%.....%%%%.....%%...........%%..............%%......%%.....%%...%%..................%%...%%.....%%....%%%..........%%%%............%%.....%%...%%......%%..%%.....%%..........................................................................................................",
"......................................................................................................................................................................................................................................................%%.......%%.....%%....%%%.....%.........%%%...%%%....%%%...%%%....%%....%%....%...%%...%%%...........%%....%%....%%.......%%....%%.....%%%....%%%.....%%.....%%...........%%.....%%....%%.....%%..%%.............%%....%%%...%%%....%%.....%%.....%%...%%....%%...%.....%%..........%%....%%......%%%%......%%%.....%...%%..............%%......%%.....%%....%%%.....%..........%%...%%....%%%...%%%...........%%%%............%%%...%%%....%%....%%...%%%...%%%....%%....................................................................................................",
"......................................................................................................................................................................................................................................................%%.......%%.....%%....%%%%%%%%%..........%%%%%%%%.....%%%%%%%%....%%....%%%%%%%...%%....%%%..........%%%%%%%%....%%.......%%%%%%%%.....%%%....%%%.....%%.....%%...........%%.....%%%%%%%%....%%....%%............%%.....%%%%%%%%....%%.....%%.....%%...%%%%%%%%...%%%%%%%...........%%%%%%%%.......%%.......%%%%%%%%%...%%..............%%%%%%..%%.....%%....%%%%%%%%%..........%%...%%%%%%%%%...%%%%%%%%%......%%..............%%%%%%%%....%%%%%%%%....%%%%%%%%....%%....................................................................................................",
"......................................................................................................................................................................................................................................................%%.......%%.....%%......%%%%%%............%%%%.%%......%%%%.%%....%%.....%%%%%....%%.....%%%.........%%.%%%%.....%%.........%%%%........%%.....%......%%.....%%...........%%.......%%%%.....%%%....%%%...........%%......%%%%.%%....%%.....%%.....%%...%%%%%%%.....%%%%%..............%%%%.........%%.........%%%%%%....%%...............%%%%%..%%.....%%......%%%%%%...........%%....%%%%%.%%...%%%%%%%%%......%%...............%%%%.%%......%%%%.......%%%%.%%....%%....................................................................................................",
".....................................................................................................................................................................................................................................................................................................%%................................................................................................................................................................%%....................................%%.......................................................................................................................................................%.............................................%%..........................................................................................................",
".....................................................................................................................................................................................................................................................................................................%%...............................................................................................................................................................%%%....................................%%......................................................................................................................................................%%............................................%%%..........................................................................................................",
".....................................................................................................................................................................................................................................................................................................%%............................................................................................................................................................%%%%%.....................................%%......................................................................................................................................................%%.......................................%%%%%%%...........................................................................................................",
".....................................................................................................................................................................................................................................................................................................%%............................................................................................................................................................%%%%......................................%%.....................................................................................................................................................%%........................................%%%%%%............................................................................................................",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
".......................................................................................................................................................................................................................................................................................................................&&.......................................................................&&.................&&.....................................................................&&&&................................................................................................................................................................&&..............................&&....................................................&&..........................................................................",
".........................................................................................................................................................................................................................................................................................................&&&&&&&&&&&&..&&.......................................................&&..............&&.................&&....................................................................&&&&&.................................&&.............................................................................................................................&&..............................&&....................................................&&..........................................................................",
".........................................................................................................................................................................................................................................................................................................&&&&&&&&&&&&..&&.......................................................&&..............&&.................&&...................................................................&&&....................................&&.....................................................................................................................&&......&&..............................&&....................................................&&..........................................................................",
"..............................................................................................................................................................................................................................................................................................................&&.......&&.......................................................................&&.................&&...................................................................&&............................................................................................................................................................&&......&&..............................&&....................................................&&..........................................................................",
"..............................................................................................................................................................................................................................................................................................................&&.......&&.......................................................................&&.................&&...................................................................&&............................................................................................................................................................&&......&&..............................&&....................................................&&..........................................................................",
"..............................................................................................................................................................................................................................................................................................................&&.......&&.&&&&........&&&&&.............&&&&&&&....&&.....&&....&&......&&&&....&&.....&&..........&&.&&&&.....&&..&&&....&&&&.....&&....&&....&&...&&.&&&&............&&&&&&....&&&&.....&&&....&&&.........&&&&....&&.....&&....&&.&&&&...&&&&.....&&.&&&&......&&&&&.............&&&&.....&&......&&.....&&&&&.....&&..&&&........&&&&&&&..&&.&&&&........&&&&&............&&....&&&&&&.....&&&&&&&&&..&&......&&...........&&&&&&&......&&&&.......&&&&&&&..................................................",
"..............................................................................................................................................................................................................................................................................................................&&.......&&&&&&&&.....&&&&&&&&...........&&&&&&&&....&&.....&&....&&....&&&&&&&...&&....&&...........&&&&&&&&....&&&&&&&..&&&&&&&&...&&....&&....&&...&&&&&&&&...........&&&&&&..&&&&&&&&....&&....&&..........&&&&....&&.....&&....&&&&&&&&.&&&&&&....&&&&&&&&....&&&&&&&..........&&&&&&&&....&&....&&....&&&&&&&&....&&&&&&&........&&&&&&&..&&&&&&&&.....&&&&&&&&...........&&....&&&&&&&....&&&&&&&&&...&&....&&...........&&&&&&&&....&&&&&&&&....&&&&&&&&..................................................",
"..............................................................................................................................................................................................................................................................................................................&&.......&&&...&&&....&&....&&&..........&&....&&....&&.....&&....&&....&&....&...&&...&&............&&&...&&&...&&&......&&....&&....&&...&&&..&&....&&&...&&&...........&&.....&&....&&.....&&..&&.............&&....&&.....&&....&&&...&&&&...&&&...&&&...&&&..&&.....&..........&&....&&....&&....&&....&&....&&&...&&&.............&&......&&&...&&&....&&....&&&..........&&.........&&&.........&&&...&&....&&...........&&....&&....&&....&&....&&....&&..................................................",
"..............................................................................................................................................................................................................................................................................................................&&.......&&.....&&...&&......&&.........&&.....&&....&&.....&&....&&...&&.........&&..&&.............&&.....&&...&&......&&......&&...&&..&&&&..&&....&&.....&&...........&&....&&......&&.....&&&&..............&&....&&.....&&....&&.....&&.....&&...&&.....&&..&&...............&&......&&...&&....&&...&&......&&...&&..............&&......&&.....&&...&&......&&..........&&..........&&........&&&....&&....&&..........&&.....&&...&&......&&..&&.....&&..................................................",
"..............................................................................................................................................................................................................................................................................................................&&.......&&.....&&...&&&&&&&&&&.........&&.....&&....&&.....&&....&&...&&.........&&.&&..............&&.....&&...&&......&&......&&...&&..&..&..&&....&&.....&&...........&&....&&......&&.....&&&&..............&&....&&.....&&....&&.....&&.....&&...&&.....&&..&&&&.............&&......&&....&&..&&....&&&&&&&&&&...&&..............&&......&&.....&&...&&&&&&&&&&..........&&......&&&&&&.......&&&......&&..&&...........&&.....&&...&&......&&..&&.....&&..................................................",
"..............................................................................................................................................................................................................................................................................................................&&.......&&.....&&...&&&&&&&&&&.........&&.....&&....&&.....&&....&&...&&.........&&&&&..............&&.....&&...&&......&&......&&...&&..&..&..&&....&&.....&&...........&&....&&......&&......&&...............&&....&&.....&&....&&.....&&.....&&...&&.....&&...&&&&&&..........&&......&&....&&..&&....&&&&&&&&&&...&&..............&&......&&.....&&...&&&&&&&&&&..........&&....&&&&&&&&......&&&.......&&..&&...........&&.....&&...&&......&&..&&.....&&..................................................",
"..............................................................................................................................................................................................................................................................................................................&&.......&&.....&&...&&.................&&.....&&....&&.....&&....&&...&&.........&&&&&&.............&&.....&&...&&......&&......&&....&.&&..&&.&.....&&.....&&...........&&....&&......&&.....&&&&..............&&....&&.....&&....&&.....&&.....&&...&&.....&&......&&&&.........&&......&&....&&..&&....&&...........&&..............&&......&&.....&&...&&..................&&...&&&....&&.....&&&.........&..&............&&.....&&...&&......&&..&&.....&&..................................................",
"..............................................................................................................................................................................................................................................................................................................&&.......&&.....&&...&&.................&&.....&&....&&.....&&....&&...&&.........&&..&&&............&&.....&&...&&......&&......&&....&&&....&.&.....&&.....&&...........&&....&&......&&.....&&&&..............&&....&&.....&&....&&.....&&.....&&...&&.....&&........&&.........&&......&&.....&&&&.....&&...........&&..............&&......&&.....&&...&&..................&&...&&.....&&....&&&..........&&&&............&&.....&&...&&......&&..&&.....&&..................................................",
"..............................................................................................................................................................................................................................................................................................................&&.......&&.....&&....&&&.....&.........&&&...&&&....&&&...&&&....&&....&&....&...&&...&&&...........&&....&&....&&.......&&....&&.....&&&....&&&.....&&.....&&...........&&.....&&....&&.....&&..&&.............&&....&&&...&&&....&&.....&&.....&&...&&....&&...&.....&&..........&&....&&......&&&&......&&&.....&...&&..............&&......&&.....&&....&&&.....&..........&&...&&....&&&...&&&...........&&&&............&&&...&&&....&&....&&...&&&...&&&....&&............................................",
"..............................................................................................................................................................................................................................................................................................................&&.......&&.....&&....&&&&&&&&&..........&&&&&&&&.....&&&&&&&&....&&....&&&&&&&...&&....&&&..........&&&&&&&&....&&.......&&&&&&&&.....&&&....&&&.....&&.....&&...........&&.....&&&&&&&&....&&....&&............&&.....&&&&&&&&....&&.....&&.....&&...&&&&&&&&...&&&&&&&...........&&&&&&&&.......&&.......&&&&&&&&&...&&..............&&&&&&..&&.....&&....&&&&&&&&&..........&&...&&&&&&&&&...&&&&&&&&&......&&..............&&&&&&&&....&&&&&&&&....&&&&&&&&....&&............................................",
"..............................................................................................................................................................................................................................................................................................................&&.......&&.....&&......&&&&&&............&&&&.&&......&&&&.&&....&&.....&&&&&....&&.....&&&.........&&.&&&&.....&&.........&&&&........&&.....&......&&.....&&...........&&.......&&&&.....&&&....&&&...........&&......&&&&.&&....&&.....&&.....&&...&&&&&&&.....&&&&&..............&&&&.........&&.........&&&&&&....&&...............&&&&&..&&.....&&......&&&&&&...........&&....&&&&&.&&...&&&&&&&&&......&&...............&&&&.&&......&&&&.......&&&&.&&....&&............................................",
".............................................................................................................................................................................................................................................................................................................................................................&&................................................................................................................................................................&&....................................&&.......................................................................................................................................................&.............................................&&..................................................",
".............................................................................................................................................................................................................................................................................................................................................................&&...............................................................................................................................................................&&&....................................&&......................................................................................................................................................&&............................................&&&..................................................",
".............................................................................................................................................................................................................................................................................................................................................................&&............................................................................................................................................................&&&&&.....................................&&......................................................................................................................................................&&.......................................&&&&&&&...................................................",
".............................................................................................................................................................................................................................................................................................................................................................&&............................................................................................................................................................&&&&......................................&&.....................................................................................................................................................&&........................................&&&&&&....................................................",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................"};

View File

@@ -0,0 +1,5 @@
### Licenses
* ImageMagick is from ImageMagick Studio LLC. See the license at [http://www.imagemagick.org/script/license.php](http://www.imagemagick.org/script/license.php)
or the [ImageMagick-license.txt](https://github.com/Alfresco/acs-community-packaging/blob/master/zip/src/main/resources/licenses/3rd-party/ImageMagick-license.txt)
file placed in the root directory of the docker image.

View File

@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>alfresco-transform-imagemagick</artifactId>
<name>Alfresco ImageMagick Transformer</name>
<packaging>jar</packaging>
<parent>
<artifactId>alfresco-transform-core</artifactId>
<groupId>org.alfresco</groupId>
<version>2.2.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-transformer-base</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>license-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

View File

@@ -0,0 +1,76 @@
/*
* #%L
* Alfresco Transform Core
* %%
* Copyright (C) 2005 - 2019 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* -
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* -
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.transformer.executors;
import java.util.HashMap;
import java.util.Map;
/**
* CommandExecutor implementation for running ImageMagick transformations. It runs the
* transformation logic as a separate Shell process.
*/
public class ImageMagickCommandExecutor extends AbstractCommandExecutor
{
private static final String ROOT = "/usr/lib64/ImageMagick-7.0.7";
private static final String DYN = ROOT + "/lib";
private static final String EXE = "/usr/bin/convert";
@Override
protected RuntimeExec createTransformCommand()
{
RuntimeExec runtimeExec = new RuntimeExec();
Map<String, String[]> commandsAndArguments = new HashMap<>();
commandsAndArguments.put(".*",
new String[]{EXE, "${source}", "SPLIT:${options}", "-strip", "-quiet", "${target}"});
runtimeExec.setCommandsAndArguments(commandsAndArguments);
Map<String, String> processProperties = new HashMap<>();
processProperties.put("MAGICK_HOME", ROOT);
processProperties.put("DYLD_FALLBACK_LIBRARY_PATH", DYN);
processProperties.put("LD_LIBRARY_PATH", DYN);
runtimeExec.setProcessProperties(processProperties);
Map<String, String> defaultProperties = new HashMap<>();
defaultProperties.put("options", null);
runtimeExec.setDefaultProperties(defaultProperties);
runtimeExec.setErrorCodes(
"1,2,255,400,405,410,415,420,425,430,435,440,450,455,460,465,470,475,480,485,490,495,499,700,705,710,715,720,725,730,735,740,750,755,760,765,770,775,780,785,790,795,799");
return runtimeExec;
}
@Override
protected RuntimeExec createCheckCommand()
{
RuntimeExec runtimeExec = new RuntimeExec();
Map<String, String[]> commandsAndArguments = new HashMap<>();
commandsAndArguments.put(".*", new String[]{EXE, "-version"});
runtimeExec.setCommandsAndArguments(commandsAndArguments);
return runtimeExec;
}
}