Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

allow user to specify frame_index for generating thumbnails from videos or pdfs #2155

Closed
wants to merge 9 commits into from

Conversation

jacobbullock
Copy link
Contributor

add optional parameter in style options to specify a frame_index to use for generating thumbnails from videos or pdfs. If no value is set, it will default to 0 to maintain default paperclip functionality.

@animated = options.fetch(:animated, true)
@auto_orient = options.fetch(:auto_orient, true)
if @auto_orient && @current_geometry.respond_to?(:auto_orient)
@current_geometry.auto_orient
end

Choose a reason for hiding this comment

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

Trailing whitespace detected.

@tute
Copy link
Contributor

tute commented Mar 29, 2016

I like this. Can you please address Hound comments, while we are on it? Also, we can achieve the initialization of the default value with options.fetch(:frame_index, 0).

Thanks for your work and contribution!

…e_index in identified_as_animated?, set default value of frame_index using options.fetch
@@ -118,4 +119,4 @@ def identified_as_animated?
raise Paperclip::Errors::CommandNotFoundError.new("Could not run the `identify` command. Please install ImageMagick.")
end
end
end
end

Choose a reason for hiding this comment

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

Final newline missing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll fix this in an update, i removed the white space in the wrong part of the file

@animated = options.fetch(:animated, true)
@auto_orient = options.fetch(:auto_orient, true)
if @auto_orient && @current_geometry.respond_to?(:auto_orient)
@current_geometry.auto_orient
end

Choose a reason for hiding this comment

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

Trailing whitespace detected.

:source => "#{File.expand_path(src.path)}#{'[' + @frame_index.to_s + ']' unless animated?}",
:dest => File.expand_path(dst.path)
)

Choose a reason for hiding this comment

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

Trailing whitespace detected.

@tute
Copy link
Contributor

tute commented Apr 28, 2016

Looking good! Can you please add a regression test for this? Also, can you address the new Hound comments? Thank you very much for sharing your work! 😃

@jacobbullock
Copy link
Contributor Author

i'll try to wrap all of this up this week. been busy launching this new product

@tute
Copy link
Contributor

tute commented May 9, 2016

@jacobbullock congrats on your launch! And don't forget your good PR! :)

success = convert(parameters,
:source => "#{File.expand_path(src.path)}#{'[' + @frame_index.to_s + ']' unless animated?}",
:dest => File.expand_path(dst.path),
)

Choose a reason for hiding this comment

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

Align ) with (.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tute do you what they want here for alignment?

@jacobbullock
Copy link
Contributor Author

@tute should I add the test in spec/thumbnail_spec.rb?

@tute
Copy link
Contributor

tute commented May 12, 2016

New tests in spec/thumbnail_spec.rb sound good. Also, can you please address Hound comments? Thank you!

@tute
Copy link
Contributor

tute commented Aug 16, 2016

ping @jacobbullock. Thank you!

…against multi-frame file formats before allow a specified frame index
…source files and to verify an error is thrown if the frame specified is out of bounds
before do
@thumb = Paperclip::Thumbnail.new(@file, geometry: "50x50", frame_index: 20, format: :jpg)
end

Choose a reason for hiding this comment

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

Trailing whitespace detected.


#List of multi frame formats to check against the source file type
#this is not an exhaustive list, should be updated to include more formats

Choose a reason for hiding this comment

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

Missing space after #.

format: :jpg,
)
end

Choose a reason for hiding this comment

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

Trailing whitespace detected.

geometry: "50x50",
frame_index: 20,
format: :jpg,
)

Choose a reason for hiding this comment

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

Align ) with (.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tute can you help me out with what Hound wants here? I have tried a few different options for aligning the ( ), but it keeps reporting errors

@jacobbullock
Copy link
Contributor Author

@tute I think the rest of these issues are just minor things. Hound is reporting some things I don't understand, like it's asking me to use the hash syntax, when I am using the hash syntax.

let me know if you want me to address anything else here.

@bdewater
Copy link
Contributor

bdewater commented Aug 20, 2016

Hound is asking you to use 1.9 hash syntax, e.g. { key: "value" } instead of { :key => "value" }. The project itself is setting a bad example by still using the old 'hash rocket' syntax.

@jacobbullock
Copy link
Contributor Author

@bdewater tired eyes, I thought it was talking about the #{ } syntax in strings. Thanks for clarifying. =)

@tute tute closed this in 8b16370 Aug 23, 2016
@tute
Copy link
Contributor

tute commented Aug 23, 2016

Merged into master. Thank you! :)

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

Successfully merging this pull request may close these issues.

4 participants