Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7925759
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T18:26:37+00:00 2026-06-03T18:26:37+00:00

We have recently started using ImageResizer.Net over GDI+ for dynamically resizing images on our

  • 0

We have recently started using ImageResizer.Net over GDI+ for dynamically resizing images on our ASP.NET MVC 4 application.

Is there a way, using only ImageResizer, to determine the actual resolution(DPI,PPI, whatever you want to call it), of the image (which is read in as a byte array). We currently have a workflow like this, to resize the image to a specified lower resolution when needed:

//pseudo-code
var image = (Bitmap)Bitmap.FromStream(contentStream)
var resX = image.HorizontalResolution;
var resY = image.VerticalResolution;
//calculate scale factor
//determine newHeight and newWidth from scale
var settings = new ResizeSettings("width={newWidth}&height={newHeight}")
var newImage = ImageBuilder.Current.Build(image, someNewImage, settings);

This works fine, but its mixing GDI+ and ImageResizer, and has alot of stream opening and closing of the same data (the actual code is a bit more verbose, with many using statements).

Is there a way to determine the Horizontal and Vertical Resolution using just ImageResizer? I couldn’t immediately find anything in the documentation.

For the moment, we have used the managed api, but will eventually use the MVC routing.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T18:26:40+00:00Added an answer on June 3, 2026 at 6:26 pm

    This is a rather atypical scenario – normally incoming DPI values are worthless.

    However, since it appears you control those values, and need them to perform sizing calculations, I suggest a plugin. They’re easy, and offer ideal performance since you’re not duplicating effort.

    public class CustomSizing:BuilderExtension, IPlugin {
    
        public CustomSizing() { }
    
        public IPlugin Install(Configuration.Config c) {
            c.Plugins.add_plugin(this);
            return this;
        }
    
        public bool Uninstall(Configuration.Config c) {
            c.Plugins.remove_plugin(this);
            return true;
        }
        //Executes right after the bitmap has been loaded and rotated/paged
        protected override RequestedAction PostPrepareSourceBitmap(ImageState s) {
            //I suggest only activating this logic if you get a particular querystring command.
            if (!"true".Equals(s.settings["customsizing"], 
                StringComparison.OrdinalIgnoreCase)) return RequestedAction.None;
    
            //s.sourceBitmap.HorizontalResolution
            //s.sourceBitmap.VerticalResolution
    
            //Set output pixel dimensions and fit mode
            //s.settings.Width = X;
            //s.settings.Height = Y;
            //s.settings.Mode = FitMode.Max;
    
            //Set output res.
            //s.settings["dpi"] = "96";
            return RequestedAction.None;
        }
     }
    

    Installation can be done through code or via Web.Config.

    new CustomSizing().Install(Config.Current);

    or in the resizer’s configuration section:

       <plugins>
         <add name="MyNamespace.CustomSizing" />
       </plugins>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have recently started using ASP.Net MVC 3 RC 2 and have attempted to
We recently started using Eclipse to develop our java application and have been running
We have recently started using FxCop on our code base and I am in
I have recently started creating an iPhone application using Appcelerator's Titanium. Since the application
I have recently started testing for my android application using Instrumentation framework. I have
I have recently started using CAML.NET IntelliSense for SharePoint with Visual Studio 2008; which
I recently started using Silex. I have been grouping certain functionality of my application
I have recently started using Vim as my text editor and am currently working
I have recently started using DocCheck for checking the validity of JavaDoc's in code
I have recently started using Zend Studio which has reported as warning the following

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.