Hi Stephen,
I have observed the requirements shared by you and regret to share that at present the support for setting relative image height is not working in Aspose.Slides for .NET 14.1.2 for Picture Frame at the moment. I have added an issue with ID SLIDESNET-35103 to further investigate the issue and provide requested support.
However, the same feature is presently avaiable in legacy Aspose.Slides for .NET 8.4.0 API and you may please use the following sample code to serve the purpose for the time being.
public static void TestRelativeHeight()
{
Presentation pres = new Presentation(“D:\Aspose Data\34419.pptx”);
PictureFrame pf = pres.Slides[0].Shapes[0] as PictureFrame;
pf.RelativeScaleHeight = 0.8f;
pf.RelativeScaleWidth = 1.35f;
pres.Write(“D:\Aspose Data\34419 out.pptx”);
}
Many Thanks,
Hi,
I am working with Stephen on the same project for the issue identified above. We would really love to continue to use Version 14 with the unified framework, but image scaling is giving us much troubles.
Essentially when adding a new image into the presentation it automatically seems to choose a random scale. All we want is to add a brand new PictureFrame with scale defaulting to 100%x100%. The fact that there is no way to make the PictureFrame stay at normal scale is almost making this version unusable for us.
Are you able to identify any workaround for us to use normally scaled PictureFrames? We do not require the ability to adjust the scaling, just need it to be standard scaling by default?
Any help is greatly appreciated.
Thanks,
Travis
Hi Travis,
I have verified the issue status from our issue tracking system and regret to share that the issue is still unresolved. However, I have raised the priority of the issue to High and have also requested our development team to kindly expedite the investigation. Unfortunately, at the moment there is no workaround that I may offer in this regard. All you can do is to set the bounds for PictureFrame and image gets accommodated inside that.
I will share the further feedback with you as soon as it will be shared by our development team in this regard.
Many Thanks,
The issues you have found earlier (filed as SLIDESNET-35103) have been fixed in this update.
This message was posted using Notification2Forum from Downloads module by Aspose Notifier.
(1)
same issue with java, I have tested Aspose.Slides for java version 16.12.0, but I still get 133%, can I conclude this issue is not resolved for java ?
Hi,
Presentation presentation = createPresentation(“EmptyPage.pptx”);
byte[] imageBytes = loadFileBytes(“testImage.jpg”);
ISlideCollection slides = presentation.getSlides();
IGlobalLayoutSlideCollection layoutSlides = presentation.getLayoutSlides();
ILayoutSlide layoutSlide = layoutSlides.get_Item(0);
ISlide islide = slides.addEmptySlide(layoutSlide);
IPPImage imgx = presentation.getImages().addImage(new ImageContent(imageBytes).getContent());
PictureFrame pf =
(PictureFrame)islide.getShapes().addPictureFrame(ShapeType.Rectangle, 10, 20, imgx.getWidth(), imgx.getHeight(), imgx);
pf.setRelativeScaleHeight(1.0f);
pf.setRelativeScaleWidth(1.0f);
presentation.save(new ByteArrayOutputStream(), SaveFormat.Pptx, new LoadOptions());
//////////////////////////////////////
the above is the code I created the issue. attached testImageScale.pptx is the result file. if you open it with PowerPoint at slide 2, right click the image -> Size and Position, you will see that the Scale height and Scale width are set at 96%
actually we did many tests, as long as the image is horizontally wide, it will be scaled to 96%.
Hi,
are you able to reproduce the scenario as I described ?
Hi,
you are using addImage(java.awt.image.BufferedImage p1)
we are using com.aspose.slides.IPPImage addImage(byte[] p1)
it is different API provided in the interface: public interface IImageCollection
extends IGenericCollection
please try the byte array API to reproduce the scenario we have found.
in the example code I show you, all you need to do is:
byte[] imageBytes = IOUtils.loadFileAsByte(path, “testImage.jpg”);
IPPImage imgx = presentation.getImages().addImage(imageBytes);
Hi,
I have tested using loading the image file as byte array and result is still the same on my end using Aspose.Slides for Java 16.12.0. For your kind reference, I have attached the generated presentation and used sample code as well.
public static void TestImageAdd() throws IOException
{
String path=“c:\Aspose Data\Test\”;
Presentation presentation = new Presentation(“c:\Aspose Data\Test\EmptyPage.pptx”);
//byte[] imageBytes = IOUtils.loadFileAsByte( path+“testImage.jpg”);
Path fileLocation = Paths.get(path+“testImage.jpg”);
byte[] imageBytes = Files.readAllBytes(fileLocation);
IPPImage imgx = presentation.getImages().addImage(imageBytes);
ISlideCollection slides = presentation.getSlides();
IGlobalLayoutSlideCollection layoutSlides = presentation.getLayoutSlides();
ILayoutSlide layoutSlide = layoutSlides.get_Item(0);
ISlide islide = slides.addEmptySlide(layoutSlide);
PictureFrame pf =
(PictureFrame)islide.getShapes().addPictureFrame(ShapeType.Rectangle, 10, 20, imgx.getWidth(), imgx.getHeight(), imgx);
pf.setRelativeScaleHeight(1.0f);
pf.setRelativeScaleWidth(1.0f);
presentation.save(path+“SavedFile.pptx”, SaveFormat.Pptx);
}
Many Thanks,
I have tested with the code you have provided. I have not changed anything besides the file location. I am using Aspose.Slides 16.12.0, I still get 96% as the result. Have you tested in Linux box? We are working on Linux box. our java version is jdk17. let me know if you need any more information.
Hi,
I have observed your comments. Can you please share the generated output that you obtained using Aspose.Slides for Java 16.12.0 on your end.
Many Thanks,
Hi,
Right click the file I attached -> 7-zip open archive;
Open the Presentation.xml, we can see the file is generated by Aspose.Slides for Java 16.12.0.0.
if you open the file with PowerPoint, check the image size, you will see both height and width are scaled at 96%.
I am using the code you provided. did not add any other code.
Please investigate.
Hi,
When I view the generated pptx on my Windows box, my current Windows OS display scale settings are at 100%. However, I am curious why Aspose.Slides(?) would use the Windows OS display settings. Since I am utilizing Aspose.Slides on a Linux environment to insert and scale the image, Aspose.Slides would not have access to any of the Windows OS display settings. Furthermore if on the same Linux environment I generated a PDF with Aspose.Slides right after I inserted the scaled image, are you suggesting that the image scale (and size) would be undetermined until it was viewed on a Windows machine?
Hi,