{"id":13790574,"url":"https://github.com/weggetor/BBImageHandler","last_synced_at":"2025-05-12T09:32:52.342Z","repository":{"id":98436531,"uuid":"70885309","full_name":"weggetor/BBImageHandler","owner":"weggetor","description":"The BBImageHandler for DotNetNuke and ASP.NET gives users and module programmers the opportunity to use a handler that displays resized images, adds watermarks to images, creates  thumbnails of web pages or displays images stored in a database table without storing them to harddisk. Additionally it could be used to create a counter display. Use for DNN version \u003c 8.0.0","archived":false,"fork":false,"pushed_at":"2016-10-14T12:36:36.000Z","size":17104,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-18T05:38:12.941Z","etag":null,"topics":["dnn","dnn-cms","image-processing","imagehandler"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/weggetor.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-10-14T07:29:32.000Z","updated_at":"2018-07-26T09:33:17.000Z","dependencies_parsed_at":null,"dependency_job_id":"0ee64efe-f402-4bb5-afb5-54c5acfdc036","html_url":"https://github.com/weggetor/BBImageHandler","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weggetor%2FBBImageHandler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weggetor%2FBBImageHandler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weggetor%2FBBImageHandler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weggetor%2FBBImageHandler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/weggetor","download_url":"https://codeload.github.com/weggetor/BBImageHandler/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253709361,"owners_count":21951124,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dnn","dnn-cms","image-processing","imagehandler"],"created_at":"2024-08-03T22:00:47.012Z","updated_at":"2025-05-12T09:32:49.898Z","avatar_url":"https://github.com/weggetor.png","language":"C#","funding_links":[],"categories":["Awesome DNN (DotNetNuke) [![Awesome](https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg)](https://github.com/sindresorhus/awesome)"],"sub_categories":["Open Source Modules"],"readme":"﻿## Project Description\n\n* * *\n\nThe BBImageHandler for DotNetNuke and ASP.NET gives users and module programmers the opportunity to use a handler that displays resized images, adds watermarks to images, creates  thumbnails of web pages or displays images stored in a database table without storing them to harddisk. Additionally it could be used to create a counter display.\n\nThe project is based on the _Microsoft.Web.GeneratedImage_ Project here on [Codeplex](http://aspnet.codeplex.com/releases/view/16449). I added a few things to that base implementation of an image handler. Rendering of gif images is improved with OctreeQuantizer, some special handlers are added and security functionality was added. Some parameters are now configurable through web.config. Barcode generation (Version 1.3) is done by open source library [ZXing.NET](https://zxingnet.codeplex.com)\n\nEven this project is declared as DNN project, it is usable by every ASP.NET application. But I added a DNN installation manifest to the downloadable install file so it could be installed in DNN with the normal installation process.\n\n## Whats new ?\n\n_Version 2.0.0 08.07.2016_  \n- New version especially for DNN8+. With DNN8 comes the dnnImagehandler which is basically bbimagehandler without the special extensions like barcode etc. The version 2.0.0 of bbimagehandler brings back this funtionality. Sourcecode and documentation is availiable on Github: [https://github.com/weggetor/BBImageHandler-8](https://github.com/weggetor/BBImageHandler-8)\n\n_Version 1.6.0 04.08.2014_  \n- Added 2 configuration properties: ServerCacheExpiration (value in seconds,Default: 600 seconds) + ClientCacheExpiration (value in seconds, Default: 300 seconds)  \n- Fixed Client Caching (now sending 304 when cache time is not expired)  \n- Fixed bug when attaching watermark to indexed image format  \n\n_Version 01.05.01 (25.03.2014):_  \n- Fixed a bug that prevented showing an Image stored in the database.  \n- Added display of weekend days in booking schedule display\n\n_Version 01.05.00 (24.02.2014):_  \n- Added generation of a “booking schedule”,  showing free, reserved + occupied state of an object for every day of 1 year\n\n_Version 01.04.00 (28.01.2014):_  \n- Added **defaultImage** parameter for an image to be displayed if error or image not available  \n- Changed DNN Profile picture parameter from \"db=ConnectionName\" to \"dnn=1\" (e.g \u003cimg src=\"bbimagehandler.ashx?dnn=1\u0026userid=7\u0026portalid=0\u0026height=150\u0026defaultimage=images/no_avatar.gif\" /\u003e  \n- Added some tolerance when parsing the **file** or **path** parameter (relative path starts at [Request.PhysicalApplicationPath](http://msdn.microsoft.com/de-de/library/system.web.httprequest.physicalapplicationpath%28v=vs.110%29.aspx))  \n- Added **ImageUrl** parameter for display of an image from another website  \n- As alternative to **File** parameter you can use p**ath** + i**ndex** (2nd image in folder xyz, alphabetical order)\n\n_Version 01.03.00 (20.01.2014):_\n- Added generation of barcodes : upca, ean8, ean13, code39, code128, itf, codabar, plessey, msi, qrcode, pdf417, aztec, datamatrix\n\n_Version 01.02.00 (25.09.2013):_\n- Added possibility to show dnn profile picture by userid and portalid  \n- Added parameters **maxwidth** and **maxheight** to delimit image size to maximum values  \n- fixed a bug when using gif images on 64 bit machines\n\n_Version 01.01.00 (01.09.2013):_  \n- Added security for db-type image generation  \n- Added gamma,contrast,brightness,inverting + flipping images  \n- Added percentage indicator generation  \n- Added placeholder image generation  \n- Improved webpage thumbnail generation\n\n_Version 01.00.01 (23.06.2011):_  \n- Initial release\n\n## Installation\n\n* * *\n**for DNN**: Use the normal installation of DNN  \n**for all other ASP.NET Websites**: Unzip install file, copy DLL to bin-folder, copy bbimagehandler.ashx file to web root and add the following to your web.config’s appSettings section:\n\n```xml\n\u003cadd key=\"BBImageHandler\" value=\"EnableClientCache=true;EnableServerCache=true;EnableSecurity=true;EnableSecurityExceptions=true;ImageCompression=90\u0026AllowedDomains=bitboxx.com\" /\u003e\n```\n\n#### Parameters:\n\n*   **EnableClientCache**: Set to true if client caching should be enabled\n*   **EnableServerCache**: Set to true if server caching should be enabled\n*   **EnableSecurity**: If set to true, only using bbimagehandler in a web page is allowed. Direct usage (eg: entering address in browser, no referer) is prohibited.  Also using it in a different domain is not possible (web page from http://www.domain-a.com uses [http://www.domain-b.com/bbimagehandler.ashx](http://www.domain-b.com/bbimagehandler.ashx)...)\n*   **EnableSecurityExceptions**: Set to true if security exceptions should be thrown\n*   **ImageCompression**: quality of resulting image (0..100)\n*   **AllowedDomains**: Comma separated list of Domains that should be permitted to use the imagehandler. Use \"domain.com\" to permit including all subdomains an \"www.domain.com\" to allow only referers from this special subdomain\n\n## Usage\n\n* * *\n\n### Resizing Image:\n\nResized Image including width-Tag:\n```html\n\u003cimg src=\"bbimagehandler.ashx?File=Winter.jpg\u0026width=150\" /\u003e\n```\n\n![image](Documentation/image_6.png \"image\")\n\nResized Image including height-Tag:  \n```\n\u003cimg src=\"bbimagehandler.ashx?File=Winter.jpg\u0026height=150\" /\u003e\n```\n![image](Documentation/image_9.png \"image\")\n\nResized Image with Border, BackColor and ResizeMode:  \n```html\n\u003cimg src=\"bbimagehandler.ashx?File=Winter.jpg\u0026width=150\u0026ResizeMode=FitSquare\u0026BackColor=#F58719\u0026border=10\" /\u003e \n```\n (Escape '#' with '%23' in Url!)  \n\n![image](Documentation/image_12.png \"image\")\n\n#### Parameters:\n\n*   **file**: physical path including image name (relative path starts at [Request.PhysicalApplicationPath](http://msdn.microsoft.com/de-de/library/system.web.httprequest.physicalapplicationpath%28v=vs.110%29.aspx))\n*   or **path**: path (absolute or relative path to image directory) and **index**: index of file in directory (alphabetical order)\n\n*   **width**: width in pixel of resulting image\n*   **height**: height in pixel of resulting image\n*   **maxwidth** and **maxheight**: instead of width and / or height you can use maxwidth and/or maxheight to leave the picture as it is until the width or height reaches the max value.\n*   **resizemode**:\n    *   **fit**: Fit mode maintains the aspect ratio of the original image while ensuring that the dimensions of the result do not exceed the maximum values for the resize transformation. (Needs _width_ or _height_ parameter)\n    *   **fitsquare**: Resizes the image with the given width as its longest side (depending on image direction) and maintains the aspect ratio. The image will be centered in a square area of the chosen background color (Needs _width_ parameter, _backcolor_ optional)\n    *   **crop**: Crop resizes the image and removes parts of it to ensure that the dimensions of the result are exactly as specified by the transformation.(Needs _width_ and _height_ parameter)\n*   **backcolor**: color of background or/and  border when _resizemode_ is f_itsquare_ or f_it_.\n*   **border**: border width in pixels around the image (added to width / height) when _resizemode_ is f_itsquare_ or f_it_.\n*   **format**: jpg,png,bmp or gif, defines the format of the resulting image\n\n* * *\n\n## Gamma correction\n\n```html\n\u003cimg src=\"bbimagehandler.ashx?File=Winter.jpg\u0026height=150\u0026gamma=2.5\" /\u003e\n```\n\n![image](Documentation/image_3.png \"image\")\n\n### Parameters:\n\n*   **Gamma**: Value for gamma adjustment between 0.2 and 5\n\n* * *\n\n## Brightness correction\n\n```html\n\u003cimg src=\"bbimagehandler.ashx?File=Winter.jpg\u0026height=150\u0026brightness=128\" /\u003e\n```\n![image](Documentation/image_2.png \"image\")\n\n### Parameters:\n\n*   **Brightness**: Value for brightness adjustment between -255 and +255\n\n* * *\n\n## Contrast correction\n\n```html\n\u003cimg src=\"bbimagehandler.ashx?File=Winter.jpg\u0026height=150\u0026contrast=75\" /\u003e\n```\n\n![image](Documentation/image_1.png \"image\")\n\n### Parameters:\n\n*   **Contrast**: Value for contrast adjustment between -100 and +100\n\n* * *\n\n## Greyscale\n\n```html\n\u003cimg src=\"bbimagehandler.ashx?File=Winter.jpg\u0026height=150\u0026greyscale=1\" /\u003e\n```\n\n![image](Documentation/image_4.png \"image\")\n\n### Parameters:\n\n*   **Greyscale**: Add any value\n\n* * *\n\n## Invert\n\n```html\n\u003cimg src=\"bbimagehandler.ashx?File=Winter.jpg\u0026height=150\u0026invert=1\" /\u003e\n```\n\n![image](Documentation/image_5.png \"image\")\n\n### Parameters:\n\n*   **Invert**: Add any value\n\n* * *\n\n## Rotate / Flip\n\n```html\n\u003cimg src=\"bbimagehandler.ashx?File=Winter.jpg\u0026height=150\u0026rotateflip=RotateNoneFlipY\" /\u003e\n```\n\n![image](Documentation/image_7.png \"image\")\n\n### Parameters:\n\n*   **RotateNoneFlipNone**: Specifies no clockwise rotation and no flipping.\n*   **Rotate90FlipNone**: Specifies a 90-degree clockwise rotation without flipping.\n*   **Rotate180FlipNone**: Specifies a 180-degree clockwise rotation without flipping.\n*   **Rotate270FlipNone**: Specifies a 270-degree clockwise rotation without flipping.\n*   **RotateNoneFlipX**: Specifies no clockwise rotation followed by a horizontal flip.\n*   **Rotate90FlipX**: Specifies a 90-degree clockwise rotation followed by a horizontal flip.\n*   **Rotate180FlipX**: Specifies a 180-degree clockwise rotation followed by a horizontal flip.\n*   **Rotate270FlipX**: Specifies a 270-degree clockwise rotation followed by a horizontal flip.\n*   **RotateNoneFlipY**: Specifies no clockwise rotation followed by a vertical flip.\n*   **Rotate90FlipY**: Specifies a 90-degree clockwise rotation followed by a vertical flip.\n*   **Rotate180FlipY**: Specifies a 180-degree clockwise rotation followed by a vertical flip.\n*   **Rotate270FlipY**: Specifies a 270-degree clockwise rotation followed by a vertical flip.\n*   **RotateNoneFlipXY**: Specifies no clockwise rotation followed by a horizontal and vertical flip.\n*   **Rotate90FlipXY**: Specifies a 90-degree clockwise rotation followed by a horizontal and vertical flip.\n*   **Rotate180FlipXY**: Specifies a 180-degree clockwise rotation followed by a horizontal and vertical flip.\n*   **Rotate270FlipXY**: Specifies a 270-degree clockwise rotation followed by a horizontal and vertical flip.\n\n* * *\n\n### Using watermarks:\n\n```html\n\u003cimg src=\"bbimagehandler.ashx?File=Winter.jpg\u0026height=150\u0026watermarktext=watermark\u0026watermarkfontcolor=white\u0026watermarkposition=topleft\" /\u003e\n```\n\n![image](Documentation/image_15.png \"image\")\n\n#### Parameters:\n\n*   **watermarkposition**: TopLeft, TopCenter, TopRight, CenterLeft, Center, CenterRight, BottomLeft, BottomCenter, BottomRight\n*   **watermarktext**: The text to display as watermark\n*   **watermarkfontfamily**: the font name used for watermarktext. (Default:Verdana)\n*   **watermarkfontcolor**: color name or html-color with leading '#' (eg. 'red', '#F0F0F0') (Default:Black)\n*   **watermarkfontsize**: font size (Default: 14)\n*   **watermarkopacity**: grade of opacity (0..255) (0 is transparent)\n\n* * *\n\n### Images stored in Database\n\nIf your image is stored in a database field (SqlDbType:Image), you can use the following syntax:\n```html\n\u003cimg src=\"bbimagehandler.ashx?db=SiteSqlServer\u0026table=MyImages\u0026ImageField=ImageData\u0026idField=ImageID\u0026idValue=3\u0026height=150\" /\u003e\n```\n\n![image](Documentation/image_18.png \"image\")\n\n#### Parameters:\n\n*   **db**: key of connectionstring section in web.config (for DNN normally 'SiteSqlServer')\n*   **table**: Name of the table in database\n*   **imagefield**: name of the image-field containing the image data\n*   **idfield**: name of the field containing the primary key (must be integer-id!)\n*   **idvalue**: value of id\n\n**Exposing connection strings (even just by name), database names, table names, ID field names, and ID field values may be a security concern in internet scenarios. It doesn't open up a direct attack vector but exposes more to the public than necessary.**\n\nAlternatively you can add the needed infos in your web.config in the appsettings section:\n\n```html\n\u003cadd key =\"BBDatabase\" value =\"Connectionstring=SiteSqlServer;table=MyImages;ImageField=ImageData;idField=ImageID\" /\u003e\n```\n\nwith this defined in web.config your link has much less information for attackers:\n\n```html\n\u003cimg src=\"bbimagehandler.ashx?db=BBDatabase\u0026idValue=3\u0026height=150\" /\u003e \n```\n\n### Parameters:\n\n*   **db**: key of appsetting entry in web.config (e.g. \"BBDatabase\")\n*   **idvalue**: value of id\n\n* * *\n\n### DNN Profile picture:\n\nProfile picture of a DNN User:  \n\n```html\n\u003cimg src=\"bbimagehandler.ashx?dnn=1\u0026userid=7\u0026portalid=0\u0026height=150\" /\u003e\n```\n\n![profilepic](Documentation/profilepic.jpg \"profilepic\")\n\n### Parameters:\n\n*   **dnn**: Any value (e.g. dnn=1) [Changed in V 1.4.0]\n*   **userid**: userid of the user whose profile picture should be shown\n*   **portalid**: the portalid in which the user resides\n\n**Don't forget that you can combine the most parameters (not only for the profile pic option). So it is possible to pimp your profile pic as inverted with border and watermark**\n\n![profilepic-inverted](Documentation/profilepic-inverted.jpg \"profilepic-inverted\")\n\n* * *\n\n## Web Image\n\nImage from another website  \n```html\n\u003cimg src=\"bbimagehandler.ashx?ImageUrl=http://www.bitboxx.net/Portals/0/Images/bitboxxsmall.gif\u0026width=200\"\u003e\n```\n\n![bitboxxlogo200](Documentation/bitboxxlogo200.jpg \"bitboxxlogo200\")\n\n### Parameters:\n\n*   **imageurl**: Url of the image to be displayed\n\n* * *\n\n### Webpage Thumbnail:\n\nUrl Thumbnail of Webpage:\n```html\n\u003cimg src=\"bbimagehandler.ashx?Url=http:\\www.ebay.de\u0026width=250\u0026ratio=screen\"\u003e \n```\n\n![image](Documentation/image_21.png \"image\")\n\n#### Parameters:\n\n*   **url**: Url of the Web page from which the thumbnail should be done\n*   **ratio**:\n    *   **full**: Make a thumb of the full web page (Default)\n    *   **screen**: Make a thumb with dimensions 3:2 (cut of rest)\n    *   **cinema**: Make a thumb with dimensions 16:9 (cut of rest)\n\n* * *\n\n### Counter:\n\nUsing as counter:\n```html\n\u003cimg src=\"bbimagehandler.ashx?File=Counter.gif\u0026digits=8\u0026counter=32477\" /\u003e\n```\n\n[![image](Documentation/image_thumb_7.png \"image\")](image_23.png)\n\n#### Parameters:\n\n*   **File**: Must be special counter image file with digits 0 to 9 with similar width per digit: [![image](image_thumb_8.png \"image\")](image_25.png)\n*   **digits**: No of digits.\n*   **counter**: Value to display\n\n* * *\n\n## Percentage\n\nUsing as radial percentage indicator:\n```html\n\u003cimg src=\"bbimagehandler.ashx?Percentage=40\u0026backcolor=green\" /\u003e\n```\n![image](Documentation/image_10.png \"image\")\n\n### Parameters:\n\n*   **percentage**: Percentage value\n*   **backcolor**: Color of percentage indicator\n\n* * *\n\n## Placeholder\n\nGenerates a placeholder image:\n```html\n\u003cimg src=\"bbimagehandler.ashx?placeholder=1\u0026width=150\u0026height=100\u0026color=green\u0026backcolor=lightgreen\" /\u003e\n```\n\n![image](Documentation/image_11.png \"image\")\n\n### Parameters:\n\n*   **Placeholder**: Any value (e.g. Placeholder=1)\n*   **Width**: Width of resulting image (this or Height must be defined)\n*   **Height**: Height of resulting image (this or Width must be defined)\n*   **Color**: Color of text and border (Default: dark grey, optional)\n*   **BackColor**: Backcolor of Image (Default:light grey, optional)\n*   **Text**: Text to show on image. If not used, image dimensions will be shown\n\n* * *\n\n## Barcode\n\nGenerates a barcode image:\n```html\n\u003cimg src=\"bbimagehandler.ashx?barcode=1\u0026width=150\u0026height=150\u0026type=qrcode\u0026content=this%20is%20the%20barcode%20content\" /\u003e\n```\n\n![QR-Code](Documentation/QR-Code.jpg \"QR-Code\")\n\n### Parameters:\n\n*   **barcode**: Any value (e.g. barcode=1)\n*   **type**: upca, ean8, ean13, code39, code128, itf, codabar, plessey, msi, qrcode, pdf417, aztec, datamatrix\n*   **Width**: Width of resulting barcode\n*   **Height**: Height of resulting barcode\n*   **Border**: Width of border (Specifies margin, in pixels, to use when generating the barcode. The meaning can vary by format; for example it controls margin before and after the barcode horizontally for most 1D formats.)\n*   **Content**: The content of the barcode (numeric or alphanumeric,depends on barcode type)\n\n(Barcode generation is made by open source library [ZXing.NET](https://zxingnet.codeplex.com))\n\n* * *\n\n## Booking Schedule\n\nGenerates a 1 year booking schedule image:\n```html\n\u003cimg src=\"bbimagehandler.ashx?schedule=year\u0026culture=de-DE\u0026matrix=11166111116611111661111166111116611111661111166111116611111000661111188333338833311661...\" /\u003e\n```\n\n![BookingSchedule](Documentation/BookingSchedule.png \"BookingSchedule\")\n\n### Parameters:\n\n*   **schedule**: Any value (e.g. schedule=year)\n*   **backcolor**: color of background (optional, default = white)\n*   **culture**: Culture abbrev (e.g. \"en-us\"). Needed for displaying month names (optional, default is CurrentCulture)\n*   **Matrix**: String of length 12 * 31 = 372 (0 = no valid date (eg. Feb. 30), 1 = free, 2 = reserved, 3 = occupied, 4 = selected. Add +5 if weekend)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweggetor%2FBBImageHandler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fweggetor%2FBBImageHandler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweggetor%2FBBImageHandler/lists"}