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

Add support allow geometry options manual crop with original #10

Merged
merged 6 commits into from
Sep 6, 2023

Conversation

shuhei-kaneko
Copy link
Member

@shuhei-kaneko shuhei-kaneko commented Aug 14, 2023

Backgrounds & Changes

During the renovation of kinu, we will allow URLs like the following.

/images/{model_name}/w=300,h=300,mc=true,wo=761,ho=1323,cw=354,ch=374,aw=2787,o=true/{id}.jpg

  • Added option to use original image when manually cropping in kinu.
    The order of each option in the above url was clearly defined in kinu, and the order was inconsistent within kinu-ruby, so this has been fixed.

  • Added dependency faraday-multipart

backward compatibility

I have not been able to specify both MANUAL CROPS and ORIGNIAL parameters before,
I assume that there will be no impact.

Sample codes

require 'kinu'

Kinu.configure do |c|
  c.host = 'image.tokubai.co.jp'
  c.port = nil
  c.ssl  = true
end
resource = Kinu::Resource.new(:bargain_cooking_recipes, 1000)

Case1. manual crop default

# before
resource.uri(width: 280, height: 300, manual_crop: true, width_offset: 761, height_offset: 1323, crop_width: 354, crop_height: 374, assumption_width: 2787).to_s
=> "https://image.tokubai.co.jp/images/bargain_cooking_recipes/w=280,h=300,mc=true,wo=761,ho=1323,cw=354,ch=374,aw=2787/1000.jpg"

# after
Not changed.

Case2. manual crop with original

# before
resource.uri(width: 280, height: 300, manual_crop: true, width_offset: 761, height_offset: 1323, crop_width: 354, crop_height: 374, assumption_width: 2787, original: true).to_s
=> "https://image.tokubai.co.jp/images/bargain_cooking_recipes/w=280,h=300,o=true,mc=true,wo=761,ho=1323,cw=354,ch=374,aw=2787/1000.jpg"
# --> An HTTP 404 error is returned.

# after
=> "https://image.tokubai.co.jp/images/bargain_cooking_recipes/w=280,h=300,mc=true,wo=761,ho=1323,cw=354,ch=374,aw=2787,o=true/1000.jpg"
# --> Currently, it returns the same as specifying only o=true. After kinu will have modified, so it returns manual crop with original image.

release message

Added option to use original image when manually cropping.

@shuhei-kaneko shuhei-kaneko requested a review from minois August 14, 2023 05:49
@shuhei-kaneko shuhei-kaneko force-pushed the Fix-AVAILABLE_TYPES-order branch from 2ba98d2 to 75599ef Compare August 14, 2023 05:52
@shuhei-kaneko shuhei-kaneko changed the title Fix AVAILABLE_TYPES order Add support allow geometry options manual crop with original Aug 16, 2023
Copy link
Member

@minois minois left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm~👍

Copy link
Member

@minois minois left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@shuhei-kaneko shuhei-kaneko merged commit 48495ad into master Sep 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants