Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resize the image using parameters and add image size in feed.json #86

Open
aurangzaib048 opened this issue Sep 8, 2022 · 6 comments
Open

Comments

@aurangzaib048
Copy link
Member

aurangzaib048 commented Sep 8, 2022

While process the images try to reduce the size of the images the optimal size,

As well as add a field for img_size in feed.json so that client is well aware of the size of the image and decide whether to show or not.

@petemill
Copy link
Member

I'm not so sure we need the img_size field, at least at the moment. The client will always download the images for now, and the "server" can decide if it's direct or PCDN converted.

@petemill
Copy link
Member

petemill commented Sep 20, 2022

Suggestion:
Let's "variablize" the target image pixel width so that we can experiment with it a bit and assess file size improvements.
I think we can start with 1200px width. Is that what we're currently using anyway for PCDN-converted images?

  • For width and height the best values could be width=1200 and something like height=1200/([original-width]/[original-height])
  • The resize param seems mostly to be more intelligent, so it could just be 1200:*

@mattmcalister
Copy link
Collaborator

@aurangzaib048 I don't see any PRs for this. did you already do this? if so, can you please point to it here and close the issue?

@aurangzaib048
Copy link
Member Author

aurangzaib048 commented Jun 21, 2023

@mattmcalister This is very critical because we have too many possible parameters in the image URL for image size.

  • Width (w): Sets the desired width of the image in pixels. For example, ?w=500 will resize the image to a width of 500 pixels.

  • Height (h): Sets the desired height of the image in pixels. For example, ?h=300 will resize the image to a height of 300 pixels.

  • Scale (s): Specifies a scaling factor for the image. It can be used to scale the image proportionally. For example, ?s=2 will double the dimensions of the image.

  • Fit (fit): Determines how the image should fit within the specified dimensions. Common options include:

  • Fit within dimensions: fit=inside or fit=max (default). The image is scaled down proportionally to fit entirely within the specified width and height.

  • Fill dimensions: fit=outside or fit=fill. The image is scaled up or down to completely fill the specified dimensions. This may result in cropping or stretching of the image.

  • Exact dimensions: fit=cover. The image is scaled and cropped to exactly cover the specified dimensions, preserving the aspect ratio.

  • Crop (crop): Specifies the cropping parameters for the image. This is often used in combination with the fit parameter to achieve specific cropping behavior. Options may include:

  • Gravity: crop=gravity, where gravity can be north, northeast, east, southeast, south, southwest, west, northwest, or center. It determines the anchor point of the crop.

  • Coordinates: crop=x,y,width,height, where x and y are the starting coordinates of the crop rectangle, and width and height are the dimensions of the crop.

  • Quality (q): Controls the image quality or compression level. It can be specified as a value between 1 and 100. Higher values indicate better quality but larger file sizes. For example, ?q=80 sets the quality to 80.

  • Format (f): Specifies the desired image format. Common options include jpg, jpeg, png, gif, etc. For example, ?f=png will convert the image to PNG format.

In contract I have improved the image selection criteria here. Now we are getting the best quality image.

@fallaciousreasoning
Copy link
Collaborator

In contract I have improved the image selection criteria here. Now we are getting the best quality image.

Hey, just looking at that code for pulling out the image, it doesn't look like we do any resizing, and it doesn't look like we pick the largest image either (for example, the image at image could be smaller than the urlToImage image, or than the media_content image).

this is very critical because we have too many possible parameters in the image URL for image size.

Yeah, I agree, there are a lot of potential ways to request different sized images but I think @petemill was suggesting we just do it on the padded CDN images (where we would control the parameters)?

@aurangzaib048
Copy link
Member Author

Hey, just looking at that code for pulling out the image, it doesn't look like we do any resizing, and it doesn't look like we pick the largest image either (for example, the image at image could be smaller than the urlToImage image, or than the media_content image).

Hey @fallaciousreasoning The urlToImage contain the best quality image and a single entry that’s why we don’t need to check it.

Yeah, I agree, there are a lot of potential ways to request different sized images but I think @petemill was suggesting we just do it on the padded CDN images (where we would control the parameters)?

And we can’t control the parameters in the padded images.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants