I’m trying to use the example Resize Image with Format Change|Documentation - Without Storage Java but I get PostImageResizeRequest cannot be resolved to a type.
I searched but couldn’t find what it could be… I don’t know if there’s something missing…
Thanks
We are sorry for the inconvenience. It seems the documentation includes the old example. Please find below the working code and check unit tests from Aspose.Imaging Cloud GitHub repository for more details. We will also fix the documentation soon.
String Client_ID = "xxxxx-xxxx-xxxx-xxxx-xxxxxxx"; // Get Client ID and Client Secret from https:dashboard.aspose.cloud/
String Client_Secret = "xxxxxxxxxxxxxxxxxxxx"; // Get Client ID and Client Secret from https:dashboard.aspose.cloud/
String BaseUrl="https://api.aspose.cloud";
ImagingApi imagingApi = new ImagingApi(Client_Secret, Client_ID, BaseUrl);
String format = "gif";
Integer newWidth = 100;
Integer newHeight = 150;
String outPath = null; // Path to updated file (if this is empty, response contains streamed image).
String storage = null; // We are using default Cloud Storage
byte[] inputStream = Files.readAllBytes(Paths.get("C:/Temp", "Test.jpeg"));
CreateResizedImageRequest createResizedImageRequest = new CreateResizedImageRequest(
inputStream, newWidth, newHeight, format, outPath, storage);
System.out.println(String.format("Call CreateResizedImageRequest with params: new width: %s, new height: %s, format: %s", newWidth, newHeight, format));
byte[] updatedImage = imagingApi.createResizedImage(createResizedImageRequest);
// Save updated image to local storage
FileOutputStream fos = new FileOutputStream("C:/Temp/Sample_out.gif");
fos.write(updatedImage);
fos.close();
System.out.println("Image resized.......");
Hello! Thank you for the return.
Now I get another error.
JAVA.LANG.NOCLASSDEFFOUNDERROR: ORG/SIMPLEFRAMEWORK/XML/SERIALIZER
For this line:
Call CreateResizedImageRequest with params: new width: 400, new height: 225, format: gif
I’m using the code as posted.
System.out.println(“1 ------------------------------------------ -----------------”);
String Client_ID = “xxxxxxxxxxxxxxxxxxxxxxxx”; // Get Client ID and Client Secret from https:dashboard.aspose.cloud/
String Client_Secret = “xxxxxxxxxxxxxxxxxxxxxx”; // Get Client ID and Client Secret from https:dashboard.aspose.cloud/
String BaseUrl=“https://api.aspose.cloud”;
ImagingApi imagingApi = new ImagingApi(Client_Secret, Client_ID, BaseUrl);
System.out.println(“2 ------------------------------------------ -----------------”);
String format = “gif”;
Integer newWidth = 400;
Integer newHeight = 225;
String outPath = null; // Path to updated file (if this is empty, response contains streamed image).
String storage = null; // We are using default Cloud Storage
System.out.println(“3 ------------------------------------------ -----------------”);
byte[] inputStream = Files.readAllBytes(Paths.get(“C:/Temp/”, “Test.jpeg”));
CreateResizedImageRequest createResizedImageRequest = new CreateResizedImageRequest(
inputStream, newWidth, newHeight, format, outPath, storage);
System.out.println(“4 ------------------------------------------ -----------------”);
System.out.println(String.format(“Call CreateResizedImageRequest with params: new width: %s, new height: %s, format: %s”, newWidth, newHeight, format));
byte[] updatedImage = imagingApi.createResizedImage(createResizedImageRequest);
System.out.println(“5 ------------------------------------------ -----------------”);
// Save updated image to local storage
FileOutputStream fos = new FileOutputStream(“C:/Temp/Sample_out.gif”);
System.out.println(“6 ------------------------------------------ -----------------”);
fos.write(updatedImage);
fos.close();
System.out.println(“7 ------------------------------------------ -----------------”);
System.out.println(“Image resized…”);
With valid credentials and the jar imported into eclipse.
Can you please help?
@fabiomauriciof
I am using Maven dependency as follows and am unable to notice the reported issue. If the issue persists, then please share some details to reproduce the issue.
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-imaging-cloud</artifactId>
<version>23.5</version>
</dependency>