I have managed to control some of the ImageMagick/Paperclip processing of
images by creating the following decorator.

Spree::Image.class_eval do
attachment_definitions[:attachment][:convert_options] = {
'mini' => "-strip -auto-orient -gravity center -extent 48x48",
'small' => "-strip -auto-orient -gravity center -extent 100x100",
'product' => "-strip -auto-orient -gravity center -extent 250x250",
'large' => "-strip -auto-orient -gravity center -extent 600x600"
}
end


However, I am discovering that the order of parameters passed to convert is
important ans specifically, if I want to -trim the images, I need to do
that before the -resize flag. I am not clear where I can control that
entire set of parameters passed to convert since the -resize
paperclip_style flag is passed in first.

Any suggestions on how to control the entire set of parameters?

Appreciate the help.

--
You received this message because you are subscribed to the Google Groups "Spree" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spree-user+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Randy Terbush at Mar 27, 2013 at 10:54 pm
    Developing a bad habit of talking to myself in here... :-)

    I've worked out a hacky solution thanks to some input from @jotto. You can
    see what I came up with here.

    https://gist.github.com/jotto/5256221

    On Wednesday, March 27, 2013 10:52:44 AM UTC-6, Randy Terbush wrote:

    I have managed to control some of the ImageMagick/Paperclip processing of
    images by creating the following decorator.

    Spree::Image.class_eval do
    attachment_definitions[:attachment][:convert_options] = {
    'mini' => "-strip -auto-orient -gravity center -extent 48x48",
    'small' => "-strip -auto-orient -gravity center -extent 100x100",
    'product' => "-strip -auto-orient -gravity center -extent 250x250",
    'large' => "-strip -auto-orient -gravity center -extent 600x600"
    }
    end


    However, I am discovering that the order of parameters passed to convert
    is important ans specifically, if I want to -trim the images, I need to do
    that before the -resize flag. I am not clear where I can control that
    entire set of parameters passed to convert since the -resize
    paperclip_style flag is passed in first.

    Any suggestions on how to control the entire set of parameters?

    Appreciate the help.
    --
    You received this message because you are subscribed to the Google Groups "Spree" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to spree-user+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Nate Lowrie at Mar 28, 2013 at 1:44 pm
    Randy,

    The arguments are just standard ImageMagik arguments. So, you can look at
    their documents to figure out what flags you need in the correct order.
    Also, a quick way to test your parameters is to use convert a sample image
    from the command line using ImageMagick. It's a much quicker way to work
    out the details compared to editing the decorator and uploading through the
    admin interface again.

    Regards,

    Nate
    On Wednesday, March 27, 2013 6:54:36 PM UTC-4, Randy Terbush wrote:

    Developing a bad habit of talking to myself in here... :-)

    I've worked out a hacky solution thanks to some input from @jotto. You can
    see what I came up with here.

    https://gist.github.com/jotto/5256221

    On Wednesday, March 27, 2013 10:52:44 AM UTC-6, Randy Terbush wrote:

    I have managed to control some of the ImageMagick/Paperclip processing of
    images by creating the following decorator.

    Spree::Image.class_eval do
    attachment_definitions[:attachment][:convert_options] = {
    'mini' => "-strip -auto-orient -gravity center -extent 48x48",
    'small' => "-strip -auto-orient -gravity center -extent 100x100",
    'product' => "-strip -auto-orient -gravity center -extent 250x250",
    'large' => "-strip -auto-orient -gravity center -extent 600x600"
    }
    end


    However, I am discovering that the order of parameters passed to convert
    is important ans specifically, if I want to -trim the images, I need to do
    that before the -resize flag. I am not clear where I can control that
    entire set of parameters passed to convert since the -resize
    paperclip_style flag is passed in first.

    Any suggestions on how to control the entire set of parameters?

    Appreciate the help.
    --
    You received this message because you are subscribed to the Google Groups "Spree" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to spree-user+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Randy Terbush at Mar 28, 2013 at 1:59 pm
    It is actually more difficult than that Nate. I'm progressing. :-)

    The problem is the order of the arguments that Paperclip constructs.

    In standard Paperclip, if I add the flags that I need in the decorator to
    add additional flags for each style, all of the :convert_options will be
    added AFTER, the -resize operation in Paperclip. So for example, if you
    want to change the filter that the -resize operation uses, passing a
    -filter flag after the -resize flag will have no effect. Biggest discovery
    here was that the order of flags passed to convert is important.

    If you want to -trim whitespace from the image, adding a -trim after the
    -resize will not produce the results you are after.

    So the change in the gist allows you to add the :convert options before the
    -resize flag and the hack is that I added a few enhancement and extent
    flags after the resize operation.

    What would be nice to do is to create :before_ops and :after_ops settings
    for the :attachment definitions, but that change eluded me.



    --
    Randy

    On Thu, Mar 28, 2013 at 7:44 AM, Nate Lowrie wrote:

    Randy,

    The arguments are just standard ImageMagik arguments. So, you can look at
    their documents to figure out what flags you need in the correct order.
    Also, a quick way to test your parameters is to use convert a sample image
    from the command line using ImageMagick. It's a much quicker way to work
    out the details compared to editing the decorator and uploading through the
    admin interface again.

    Regards,

    Nate
    On Wednesday, March 27, 2013 6:54:36 PM UTC-4, Randy Terbush wrote:

    Developing a bad habit of talking to myself in here... :-)

    I've worked out a hacky solution thanks to some input from @jotto. You
    can see what I came up with here.

    https://gist.github.com/jotto/**5256221<https://gist.github.com/jotto/5256221>

    On Wednesday, March 27, 2013 10:52:44 AM UTC-6, Randy Terbush wrote:

    I have managed to control some of the ImageMagick/Paperclip processing
    of images by creating the following decorator.

    Spree::Image.class_eval do
    attachment_definitions[:attac**hment][:convert_options] = {
    'mini' => "-strip -auto-orient -gravity center -extent 48x48",
    'small' => "-strip -auto-orient -gravity center -extent 100x100",
    'product' => "-strip -auto-orient -gravity center -extent 250x250",
    'large' => "-strip -auto-orient -gravity center -extent 600x600"
    }
    end


    However, I am discovering that the order of parameters passed to convert
    is important ans specifically, if I want to -trim the images, I need to do
    that before the -resize flag. I am not clear where I can control that
    entire set of parameters passed to convert since the -resize
    paperclip_style flag is passed in first.

    Any suggestions on how to control the entire set of parameters?

    Appreciate the help.

    --
    You received this message because you are subscribed to a topic in the
    Google Groups "Spree" group.
    To unsubscribe from this topic, visit
    https://groups.google.com/d/topic/spree-user/L5bgZEtZTVs/unsubscribe?hl=en-US
    .
    To unsubscribe from this group and all its topics, send an email to
    spree-user+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

    --
    You received this message because you are subscribed to the Google Groups "Spree" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to spree-user+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Nate Lowrie at Mar 28, 2013 at 2:52 pm
    Ah, I see now. Glad you are working things out.

    +1 from me for the before and after resize options preferences.

    Regards,

    Nate
    On Thursday, March 28, 2013 9:58:57 AM UTC-4, Randy Terbush wrote:

    It is actually more difficult than that Nate. I'm progressing. :-)

    The problem is the order of the arguments that Paperclip constructs.

    In standard Paperclip, if I add the flags that I need in the decorator to
    add additional flags for each style, all of the :convert_options will be
    added AFTER, the -resize operation in Paperclip. So for example, if you
    want to change the filter that the -resize operation uses, passing a
    -filter flag after the -resize flag will have no effect. Biggest discovery
    here was that the order of flags passed to convert is important.

    If you want to -trim whitespace from the image, adding a -trim after the
    -resize will not produce the results you are after.

    So the change in the gist allows you to add the :convert options before
    the -resize flag and the hack is that I added a few enhancement and extent
    flags after the resize operation.

    What would be nice to do is to create :before_ops and :after_ops settings
    for the :attachment definitions, but that change eluded me.



    --
    Randy


    On Thu, Mar 28, 2013 at 7:44 AM, Nate Lowrie <na...@finelineautomation.com<javascript:>
    wrote:
    Randy,

    The arguments are just standard ImageMagik arguments. So, you can look at
    their documents to figure out what flags you need in the correct order.
    Also, a quick way to test your parameters is to use convert a sample image
    from the command line using ImageMagick. It's a much quicker way to work
    out the details compared to editing the decorator and uploading through the
    admin interface again.

    Regards,

    Nate
    On Wednesday, March 27, 2013 6:54:36 PM UTC-4, Randy Terbush wrote:

    Developing a bad habit of talking to myself in here... :-)

    I've worked out a hacky solution thanks to some input from @jotto. You
    can see what I came up with here.

    https://gist.github.com/jotto/**5256221<https://gist.github.com/jotto/5256221>

    On Wednesday, March 27, 2013 10:52:44 AM UTC-6, Randy Terbush wrote:

    I have managed to control some of the ImageMagick/Paperclip processing
    of images by creating the following decorator.

    Spree::Image.class_eval do
    attachment_definitions[:attac**hment][:convert_options] = {
    'mini' => "-strip -auto-orient -gravity center -extent 48x48",
    'small' => "-strip -auto-orient -gravity center -extent 100x100",
    'product' => "-strip -auto-orient -gravity center -extent 250x250",
    'large' => "-strip -auto-orient -gravity center -extent 600x600"
    }
    end


    However, I am discovering that the order of parameters passed to
    convert is important ans specifically, if I want to -trim the images, I
    need to do that before the -resize flag. I am not clear where I can control
    that entire set of parameters passed to convert since the -resize
    paperclip_style flag is passed in first.

    Any suggestions on how to control the entire set of parameters?

    Appreciate the help.

    --
    You received this message because you are subscribed to a topic in the
    Google Groups "Spree" group.
    To unsubscribe from this topic, visit
    https://groups.google.com/d/topic/spree-user/L5bgZEtZTVs/unsubscribe?hl=en-US
    .
    To unsubscribe from this group and all its topics, send an email to
    spree-user+...@googlegroups.com <javascript:>.
    For more options, visit https://groups.google.com/groups/opt_out.

    --
    You received this message because you are subscribed to the Google Groups "Spree" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to spree-user+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupspree-user @
categoriesrubyonrails
postedMar 27, '13 at 4:52p
activeMar 28, '13 at 2:52p
posts5
users2
websitespreecommerce.com
irc#RubyOnRails

2 users in discussion

Randy Terbush: 3 posts Nate Lowrie: 2 posts

People

Translate

site design / logo © 2022 Grokbase