class Flickr::Object::Photo
Probably the most important class in this library.
## Sizes
It has an interface for assigning the photo’s size. Current Flickr’s photo sizes are:
-
Square 75/150
-
Thumbnail
-
Medium 500/640/800
-
Large 1024/1600/2048
-
Original
Important: When fetching photos, the information about the sizes (URL, width, height) isn’t automatically available. If you’re fetching multiple photos (e.g. using ‘Flickr.photos.search`), you need to pass `:sizes => true`. For individual photos, use get_sizes.
Any of the following ways will change the photo’s size to “Medium 500”:
photo.medium500! photo.medium!(500) photo.medium!("500")
A change to photo’s size affects the following attributes: {#source_url}, {#width} and {#height}.
You may often just want to assign the largest possible size to the photo:
photo.largest!
You may also want to assign the largest size to the photo, but that it’s not larger/smaller than “Medium 500”:
photo.medium500_or_smaller! photo.medium500_at_least!
Note: The corresponding non-bang versions of the methods are also available:
photo.medium500 photo.medium(500) photo.medium("500") photo.largest photo.medium500_or_smaller photo.medium500_at_least
However, these are not recommended, since they duplicate the photo, taking up twice as much memory. Use them only if you really have to.
Constants
- SIZES
Public Instance Methods
@return [response] @see Flickr::Api::Photo#delete
# File lib/flickr/object/photo.rb, line 268 def delete(params = {}) api.delete(id, params) end
@return [self] @see Flickr::Api::Photo#get_exif
# File lib/flickr/object/photo.rb, line 251 def get_exif!(params = {}) photo = api.get_exif(id, params) update(photo.attributes) end
@return [Flickr::Object::List<Flickr::Object::Person>] @see Flickr::Api::Photo#get_favorites
# File lib/flickr/object/photo.rb, line 260 def get_favorites(params = {}) api.get_favorites(id, params) end
@return [self] @see Flickr::Api::Photo#get_info
# File lib/flickr/object/photo.rb, line 233 def get_info!(params = {}) photo = api.get_info(id, params) update(photo.attributes) end
@return [self] @see Flickr::Api::Photo#get_sizes
# File lib/flickr/object/photo.rb, line 242 def get_sizes!(params = {}) photo = api.get_sizes(id, params) update(photo.attributes) end
@return [self]
# File lib/flickr/object/photo.rb, line 212 def largest dup.largest! end
@return [self]
# File lib/flickr/object/photo.rb, line 205 def largest! size! largest_size end
@return [response] @see Flickr::Api::Photo#remove_tag
# File lib/flickr/object/photo.rb, line 302 def remove_tag(tag_or_id, params = {}) api.remove_tag(id, tag_or_id, params) end
@return [response] @see Flickr::Api::Photo#set_content_type
# File lib/flickr/object/photo.rb, line 276 def set_content_type(content_type, params = {}) api.set_content_type(id, content_type, params) end
@return [response] @see Flickr::Api::Photo#set_dates
# File lib/flickr/object/photo.rb, line 310 def set_dates(params = {}) api.set_dates(id, params) end
@return [response] @see Flickr::Api::Photo#set_license
# File lib/flickr/object/photo.rb, line 342 def set_license(license_id, params = {}) api.set_license(id, license_id, params) end
@return [response] @see Flickr::Api::Photo#set_meta
# File lib/flickr/object/photo.rb, line 318 def set_meta(params = {}) api.set_meta(id, params) end
@return [response] @see Flickr::Api::Photo#set_permissions
# File lib/flickr/object/photo.rb, line 326 def set_permissions(params = {}) api.set_permissions(id, params) end
@return [response] @see Flickr::Api::Photo#set_safety_level
# File lib/flickr/object/photo.rb, line 334 def set_safety_level(params = {}) api.set_safety_level(id, params) end
The size of the photo, can be changed with modifer methods (see the definition of this class for details).
@return [String]
# File lib/flickr/object/photo.rb, line 127 def size @size.name if @size end
Changes the size of the photo.
# File lib/flickr/object/photo.rb, line 219 def size!(name) if name != nil and not Size.exists?(name) raise ArgumentError, "\"#{name}\" isn't a valid photo size" end @size = Size.new(name) self end