classdef JPEGImageCoderItem < CoderItem

    methods
        function obj=JPEGImageCoderItem(inputparams)
            obj=obj@CoderItem(inputparams);
        end
        
        function cicoll=procItem(obj,item)
            cicoll=CodedImageItemCollection;
            for currQuality=obj.params.quality
                A=imread(item.getfilename);
                 [fpathstr,fname,fext] = fileparts(item.getfilename);
                 outfname=sprintf('%s_jpeg_%d.jpg',fname,round(currQuality));
                 fprintf('Coding %s ...\n',outfname);
                 imwrite(A,outfname, 'Quality',currQuality);
                 params.quality=currQuality;
                 params.name='JPEG';
                 ci=CodedImageItem(outfname,params,item);
                 cicoll=cicoll+ci;
            end
        end
        
    end

end