/**1* Copyright 2013 Facebook, Inc.2*3* Licensed under the Apache License, Version 2.0 (the "License");4* you may not use this file except in compliance with the License.5* You may obtain a copy of the License at6*7* http://www.apache.org/licenses/LICENSE-2.08*9* Unless required by applicable law or agreed to in writing, software10* distributed under the License is distributed on an "AS IS" BASIS,11* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12* See the License for the specific language governing permissions and13* limitations under the License.14*/15/*jslint proto:true*/1617var inherits = require('util').inherits;18var Resource = require('./Resource');192021/**22* Resource for *.png, *.jpg, *.gif files23* @extends {Resource}24* @class25* @param {String} path path of the resource26*/27function Image(path) {28Resource.call(this, path);29this.id = null;30}31inherits(Image, Resource);32Image.__proto__ = Resource;3334Image.prototype.width = 0;35Image.prototype.height = 0;36Image.prototype.type = 'Image';37Image.prototype.version = '0.1';3839Image.fromObject = function(obj) {40var image = new Image(obj.path);41image.path = obj.path;42image.width = obj.width || 0;43image.height = obj.height || 0;44image.mtime = obj.mtime;45return image;46};4748Image.prototype.toObject = function() {49var obj = {50path: this.path,51id: this.id,52type: this.type,53mtime: this.mtime54};55if (this.width) {56obj.width = this.width;57}58if (this.height) {59obj.height = this.height;60}61return obj;62};636465module.exports = Image;666768