# My crop - how to update thumbnails

**URL:** <https://www.ruby-forum.com/t/my-crop-how-to-update-thumbnails/152999>\
**Category:** Rails\
**Created:** [November 11, 2008, 12:38am UTC](https://www.ruby-forum.com/t/my-crop-how-to-update-thumbnails/152999 "2008-11-11T00:38:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tomtoday](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/35a633/32.png) [@tomtoday](https://www.ruby-forum.com/u/tomtoday)\
**Post date:** [November 11, 2008, 12:38am UTC](https://www.ruby-forum.com/t/my-crop-how-to-update-thumbnails/152999/1 "2008-11-11T00:38:52Z")

</div>

Hi,  
I made ruby do the resize based on JS cropper. The image is  
cropped and can be written to drive, but I dont know how to  
oryginal image and thumbs.

Here is the code:

def my\_crop(args={})  
x1 = args[:x1].to\_i  
y1 = args[:y1].to\_i  
new\_width = args[:width].to\_i  
new\_height = args[:height].to\_i

```
with_image do |img|
  @data = img.crop(x1, y1, new_width, new_height)
end

@data.write("c:/resized.jpg") # here I gvet the iamge correctly
# this does not work, how to make @data update thumbs?
attachment_options[:thumbnails].each do |suffix, size|
  create_or_update_thumbnail(@data, suffix, *size)
end

```

end

Its based on blog post from [http://blog.onmylist.com](http://blog.onmylist.com), but  
the oryginal code did not work for me.

Is there a way to update the thumbs?

Cheers,  
Tomasz Bak
