Search code examples
asp.netpluginsasp-classicphoto

ASP Photo Processing - List Photo colors


Like the the amazing "histogram" property in Ruby (RMagicK), that computes a list of colors in a photo, in order of frequency - is there anything similar to this for Classic ASP/.NET, in the form of a third-party plugin or component?

Regards


Solution

  • It sounds like RMagick is a derivative of ImageMagick. The Windows version has an installer that allows you to install a COM component. (You will have to check this in the installer for it to be installed). Link

    This COM component can be used from classic ASP.

    I have some classic ASP code that uses ImageMagick, the syntax is a bit unusual. Please note that this won't function on its own, because it depends om some other functions, but it will give you an idea of how to use the COM component:

    function DrawPoly(destFile, coordinates, fillcolor, strokecolor)
        ' Draws a single polygon and returns a result-image
        Dim img: Set img = CreateObject("ImageMagickObject.MagickImage.1")
        dim polygon, DrawCommand, DrawResult
            polygon = trim(coordinates)
            polygon = normalizeCoordinates(polygon,10)
            DrawCommand = "polygon " & trim(polygon)
            DrawResult  = img.Convert(Server.Mappath(destFile), "-matte", "-fill", fillColor, "-stroke", strokeColor, "-draw", DrawCommand, Server.Mappath(destFile))
            If Err.Number <> 0 Then Response.Write(Err.Number & ": " & Err.Description & vbCrLf & msgs)
        DrawPoly = destFile
        Set img = nothing
    end function
    

    I don't know how to perform a histogram, but I hope this piece of code together with the imagemagick docs will get you there.

    Erik