anchor.diff:      can_generate_preview/1,
   	out_mime/2,
       string2filter/2,
  -    cmd_args/2
  +    cmd_args/2,
  +    calc_size/7
   ]).
   
   -define(MAX_WIDTH,  5000).
  
positive.code:     {Width, Height, []};
  filter2arg({height, _}, Width, Height) ->
      {Width, Height, []};
  filter2arg({resize, EndWidth, EndHeight, false}, Width, Height) when Width < EndWidth andalso Height < EndHeight ->
      % Prevent scaling up, perform an extent instead
      GArg = "-gravity West",
      EArg = ["-extent ", integer_to_list(EndWidth),$x,integer_to_list(EndHeight)],
      % Still thumbnail to remove extra info from the image
      RArg = ["-thumbnail ", z_utils:os_escape([integer_to_list(EndWidth),$x,integer_to_list(EndHeight),$!])],
      {EndWidth, EndHeight, [GArg, 32, EArg, 32, RArg]};
  filter2arg({resize, EndWidth, EndHeight, true}, Width, Height) when Width < EndWidth andalso Height < EndHeight ->
      % Scale up
      EArg = ["-resize ", integer_to_list(EndWidth),$x,integer_to_list(EndHeight)],
      RArg = ["-thumbnail ", z_utils:os_escape([integer_to_list(EndWidth),$x,integer_to_list(EndHeight),$!])],
  
negative.code:                 ReqWidth   = z_convert:to_integer(proplists:get_value(width, Filters)),
                  ReqHeight  = z_convert:to_integer(proplists:get_value(height, Filters)),
                  {CropPar,_Filters1} = fetch_crop(Filters),
                  {ResizeWidth,ResizeHeight,CropArgs} = calc_size(ReqWidth, ReqHeight, ImageWidth, ImageHeight, CropPar, Orientation, is_enabled(upscale, Filters)),
                  case CropArgs of
                      none -> 
                          case is_enabled(extent, Filters) of
  