photoframe@cinnamon.org - bad size of photos

Add functionality to your desktop
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
seobmen
Level 1
Level 1
Posts: 12
Joined: Fri Apr 29, 2022 2:20 pm

photoframe@cinnamon.org - bad size of photos

Post by seobmen »

I use widget photoframe@cinnamon.org - LMDE. I have to write exact size of width and height of photos in preferences of desklet.
But I have photos wich have different size / proportions. And desklet stretches and compresses photos. Before several updates there was just bakground color if photo didn't have size from preferences. How can I fix it like it was before?
Last edited by LockBot on Tue Apr 04, 2023 10:00 pm, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
gadlol
Level 1
Level 1
Posts: 5
Joined: Wed May 01, 2013 9:06 am

Re: photoframe@cinnamon.org - bad size of photos

Post by gadlol »

This is happening so that the desklet does not get auto resized based on each photo. In that case it would cover unwanted space on the desktop screen. So you setup dimensions and the script tries to fit the image into that "box".

However with coding changes on the desklet.js you can achieve what you wish.

After each image load you should resize the "_photoFrame" and not the image in the "_size_pic(image)" function

Code: Select all

this._photoFrame.set_size(width, height);
and not

Code: Select all

image.set_size(width, height);
Note that the width and height of the settings must be always set and used so the image dimensions do not get bigger from the screen. Imagine loading an image that is 4000 x 3000 pixels.

I know that it works, because I have implemented a desklet that loads only one photo (you can also create multiple instances) that keeps the image ratio and loads the box based on the image dimensions and the width - height of the settings.
seobmen
Level 1
Level 1
Posts: 12
Joined: Fri Apr 29, 2022 2:20 pm

Re: photoframe@cinnamon.org - bad size of photos

Post by seobmen »

Thanks for your answer. I commented in /usr/share/cinnamon/desklets/photoframe@cinnamon.org/desklet.js

Code: Select all

            _size_pic(image) {
        image.disconnect(image._notif_id);

        let height, width;
        let imageRatio = image.width / image.height;
        let frameRatio = this.width / this.height;

        if (imageRatio > frameRatio) {
            width = this.width;
            height = this.width / imageRatio;
        } else {
            height = this.height;
            width = this.height * imageRatio;
        }

          //   image.set_size(width, height);
    }

but unfortunately it still deforms photos.
gadlol
Level 1
Level 1
Posts: 5
Joined: Wed May 01, 2013 9:06 am

Re: photoframe@cinnamon.org - bad size of photos

Post by gadlol »

Comment:

Code: Select all

image.set_size(width, height);
and add below:

Code: Select all

this._photoFrame.set_size(width, height);
This will auto resize photoframe based on image dimensions keeping the ratio based on the Height and Width from the desklet configuration.
seobmen
Level 1
Level 1
Posts: 12
Joined: Fri Apr 29, 2022 2:20 pm

Re: photoframe@cinnamon.org - bad size of photos

Post by seobmen »

I did it but it doesn't work, still deforms photos. I don't know why. But in any case thanks for your help ;)
User avatar
zcot
Level 9
Level 9
Posts: 2803
Joined: Wed Oct 19, 2016 6:08 pm

Re: photoframe@cinnamon.org - bad size of photos

Post by zcot »

The default dimension and ratio of the frame is landscape, so a portrait photo will be distorted.

If you change the frame to a portrait dimension/ratio then it will distort landscape pictures.
Locked

Return to “Compiz, Conky, Docks & Widgets”