.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Winnovative:Could not save image. Parameter is not valid.

Posted By:      Posted Date: September 10, 2010    Points: 0   Category :ASP.Net
while running website,the image get extracted from pdf document but still an exception named pdfimgextractexception appears at the end of an application.please give me the solution regarding this problem. code as follows: pdfImgExtractor.ExtractImages(srcPdfFile,true); which calls an eventhandler: pdfImgExtractor.ImageExtractedEvent += new ImageExtractedEventHandler(pcmd.pdfImgExtractor_ImageExtractedEvent); where the definition is: {   try { System.Drawing.     ographics = ographics.DrawImage(extractedBitmap, extractedBitmap.Dispose(); extractedBitmap = obitmap;     ographics.DrawString( ographics.Dispose(); ofont.Dispose(); oBrush.Dispose(); extractedBitmap.Save( extractedBitmap.Dispose(); }   {   }   Bitmap extractedBitmap = args.ExtractedBitmap;Graphics ographics;Bitmap obitmap = new Bitmap(extractedBitmap.Width, extractedBitmap.Height);Graphics.FromImage(obitmap);new Rectangle(0, 0, obitmap.Width, obitmap.Height), 0, 0, extractedBitmap.Width, extractedBitmap.Height, GraphicsUnit.Pixel);SolidBrush oBrush = new SolidBrush(Color.Black);Font ofont = new Font("Arial", 8);"Some text to write", ofont, oBrush, 10, 10);"D:\\example.jpeg", System.Drawing.Imaging.ImageFormat.Jpeg);catch (Exception err)HttpContext.Current.Response.Write(err.Message); } thanks in advance.

View Complete Post

More Related Resource Links

"Parameter is not valid" for tif image(JPEG cpmpressed)


I am agetting the "Parameter is not valid" message while converting the tif image (jpeg compressed) to the Bitmap

FileStream stream =new FileStream(strFilePath, FileMode.Open, FileAccess.Read); 
Bitmap bmp = (Bitmap)Bitmap.FromStream(stream); //here the exception occurs... 

System.Drawing.Image.FromStream() ArgumentException: Parameter not valid.


I am getting an ArgumentException: Parameter is not valid.

Does anyone know what's wrong with my code here?

        ImgService obj = new ImgService();

        byte[] data = obj.ShowImg(6);

        Int32 offset = 78;

        MemoryStream memStream = new MemoryStream();

        memStream.Write(data, offset, data.Length - offset);

        System.Drawing.Image img = System.Drawing.Image.FromStream(memStream);

        img.Save(Server.MapPath("image.jpg"), System.Drawing.Imaging.ImageFormat.Jpeg);


        Image1.ImageUrl = Server.MapPath("image.jpg");


        ImgService obj = new ImgService();

        byte[] data = obj.ShowImg(6);
        Int32 offset = 78;

Parameter is not valid exception on image.fromstream() method



      i have written a code for resizing the images and its working good except for some images that too the issue is occuring only on locolhost(IIS). I have asynchronous file upload contorl and two button  controls. when clicked on first button  the asynchronous file upload control is saved in session using the following code

Session["myupload"] = AsyncFileUpload1.PostedFile;

The image is resized and saved in a folder when second button clicked. The following code will execute when clicked the second button.

HttpPostedFile hif = (HttpPostedFile)Session["myupload"]                        
                        if (hif.ContentLength <= 20000000)
                            if (checkfiletype(hif.FileName))
                                string spacefileName = hif.FileName;                                
                                string storePath = Server.MapPath("~") + "/Docs";
                                //MemoryStream source = hif.InputStream;
                                Stream source = hif.InputStream;
                                //source =(MemoryStream)hif.InputStream;
                                byte[] input=new byte[hif.ContentLength

System.Drawing.Image.FromStream() get a Parameter is not valid


Anyone help fix Parameter is not valid errors , when i tried rename and save a file using fileupload to server

my code here :

if (fupImage.PostedFile.FileName != "")
                if (!Utitlties.Instance.CheckImageFileType(fupImage.PostedFile.FileName))
                    lblMessageForfupImage.Visible = true;
                    lblMessageForfupImage.Text = "Image file only accept *.jpg, *.png, *.bmp, *.gif Extensions !";
                    evt.ImageURL = Utils.Instance.SaveImage(fupImage.PostedFile.InputStream, fupImage.PostedFile.FileName, true);

anh here is methos SaveImage :


public string SaveImage(Stream stream, string filename, bool IsImageFile/*, bool CreateThumImage*/)
        string ImgUrl = string.Empty;
        string d = Utitlties.Instance.MakeFolderName();
        System.Drawing.Image img;
        string dirToSave = HttpContext.Current.Server.MapPath("Images/Uploads") + "/" + d + "/";
        string dir = "Images/Uploads/" + d + "/";
            if (IsImageFile == true)

image.save not saving images


I have a piece of code that writes string into an image and save it. It works on one of my site and but not the other. The image.save is not working. If this is a permission problem, which account should I change? I use win server 2003 and IIS 6, and have given ASPNET, NETWORK SERVICE, and anonymous user write access.

Getting generic GDI error when trying to save resized image

Getting following error:A generic error occurred in GDI+.
Any help is appreciated.
Public Sub SaveImageFile(ByVal sourceImage As Bitmap, ByVal saveImagePath As [String], ByVal maxImageWidth As Integer)
            ' Resize if source image width is greater than the max:

            If sourceImage.Width > maxImageWidth Then
                Dim bmp As Bitmap = TryCast(sourceImage, Bitmap)
                Dim newImageHeight As Integer = CInt(Math.Truncate(sourceImage.Height * (CSng(maxImageWidth) / CSng(sourceImage.Width))))
                Dim gr As Graphics = Graphics.FromImage(bmp)

                Dim bmpnew As New Bitmap(maxImageWidth, newImageHeight)
                gr.InterpolationMode = InterpolationMode.HighQualityBicubic

                gr.DrawImage(bmpnew, 0, 0, maxImageWidth, newImageHeight)

                'code to manipulate bmpNew goes here.



Insert image into Infopath form and save to SharePoint as PDF file


I have an InfoPath web-enabled form in MOSS 2007, that is integrated with a K2 blackpoint process for an approval workflow.

Once the form (a Purchase Order request form) has been approved in the K2 workflow process, I switch the form view to a "print-friendly" view for the requestor to view from the browser.  However, now I need to go one step further with this scenario:

1) I need to somehow insert/embed an image with the scanned-in signature of the approver (likely stored in a SP doc library) at the signature line section of my form.  Also, what are the security requirements for storing such images, but not granting all users access to these (e.g. only services accounts that need to access this for embedding into the form, etc.)?

2) Then I need to convert this final "print-friendly" view of the form (with the signature image) to a PDF document so that I can store it in SharePoint (and email it to the requestor using K2's email event capabilities).

Can anyone help me with a solution to both of these requirement, or point me to some resources for this (even 3rd party components are open-game).



"Save as image" available programatically?

Hi,With the rehosted designer it is possible to right click in the design area and choose to save the workflow as an image. This is cool functionality and was wondering if it was possible to call this programatically? This would then allow me to show an image of what the workflow looks like without having to load up the full designer.Does anyone know if this is possible or how it can be done.ThanksMatt

SSRS 2008 Export to PDF fails for large data with System.Exception: Parameter is not valid

Hi, We are working on Range Bar Chart using SSRS 2008. The report has huge data. It is properly displaying the data, but when we tried to export to pdf it is failing with the following exception. Exporting to excel works fine. Also if the report has small/medium data it is property exporting to PDF. It is failing only in case of huge data (we have custom page size of 28" X 14"). Of course the report has lot of expressions we used to customize the colors/text as per our requirements.   Server Error in '/Reports_SQLDEV2008' Application. Parameter is not valid. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Exception: Parameter is not valid. Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace:   [Exception: Parameter is not valid.]   [Exception: An error occurred during rendering of the report.]   [Exception: An error occurred during rendering of the report.]    Microsoft.Reporting.WebForms.ServerReport.ServerUrlRequest(Boolean isAbortable, String url, Stream ou

Why Image.save creates a black image

Hello, I am trying to create a screenshot, here is the code, it creates a complete black image.Thanks for any help. Public Function CaptureWindow(ByVal handle As IntPtr) As Image               ' get te hDC of the target window               Dim hdcSrc As IntPtr = User32.GetWindowDC(handle)               ' get the size               Dim windowRect As New User32.RECT()               User32.GetWindowRect(handle, windowRect)               Dim width As Integer = windowRect.right - windowRect.left               Dim height As Integer = windowRect.bottom - windowRect.top               ' create a device c

Visual Studio Extension: Save UML diagram as image

I am auditing one big legacy application. I use Visual Studio 2010 modeling projects to visualize the design of this legacy application. When I wanted to get my UML diagrams to image files so I can insert them to documents I found no option for it. As it turned out we have to write extension for modeling projects and deploy it as Visual Studio 2010 extension. Here is the installer and source package of my UML.SaveAsImage extension. UML.SaveAsImage.zip VS2010 solution | 48KB UML.SaveAsImage.Install.zip VSIX insaller | 4KB I still cannot believe that we need to write extensions to get our UML diagrams to image files but okay, it's done now and let's say - problem is solved. At least this one. In my work I used code example by Cameron Skinner. He has very good blog posting titled as Save a diagram to Image File. Here are steps how I wrote this extension. 1. Create new Layer Designer Command Extension project As a first thing you should create layer designer command extension project. If you don't have support for modeling projects you should take more powerful edition of Visual Studio 2010. Name it your project as you like and click OK. 2. Add functionality to Command class You can find Command class from your new project. This class is created by default. Here is the modified code from Cameron Ski

ASP.NET: How to Load image and save to database form clientside

Hello, can any one help? I am using HTTPHandlers for loading the image from the database I need to change the image and save it back to the database from the client side, that is I need to browse image at client side and save the image as bytes in to databases, how to do this? Regards, satish  

Uploading an image to a SQL DB via a SQLDataSource parameter


Hi all,

I've got a bit of a problem that I can't figure out.  I've got a SQL data source on a create user page that uploads the user data to a SQL database when the person creating the account clicks the "Next" button.  One of the columns in the DB is an "image" data type and I'm using the FileUpload control to do that.  Here is the ds and its info on the actual page:

<asp:SqlDataSource ID="sqldsAddMember" runat="server" ConnectionString="<%$ ConnectionStrings:myCS %>" InsertCommand="INSERT INTO [Member] ([UserName], [MemberImage]) VALUES (@UName, @Photo)">
        <asp:Parameter Name="UName" ConvertEmptyStringToNull="true" />
        <asp:Parameter Name="Photo" DbType="Binary" ConvertEmptyStringToNull="true" />

In the code-behind I have the following (it's something I found elsewhere on the web):

    Protected Sub CreateUserWizardStep1_Deactivate(ByVal sender As Object, ByVal e As System.EventArgs) Handles CreateUserWizardStep1.Deactivate
        sqldsAddMember.InsertParameters("UName").DefaultValue = Session("UserName&

save image to PC directory


i don't know why when i  save the same picture to the same directory,it causes the error message: "A generic error occred in GDI+"??????
but if i change another picute to save , it works properly

my code is as belows:
 Image img = Image.FromFile(this.picBox2.ImageLocation.ToString());
img.Save(@"D:\Temp\111.jpeg", System.Drawing.Imaging.ImageFormat.Jpeg);

how can i prevent this error when i save the same picture?

save image in new folder


i have a image which i am picking from open file dialog now i want to save image in my project folder

please hep me

Binary Data Problem....save and retrive image data from sql database


hello friends...please help me to solve this problem....

i have created crud (create, retive, update and delete)form and it's running... here i want to add images for each record(sql database)....

i'm using image datatype in sql table for picture.....

Q 1: how to save and retrive binary data(image) from sql table in asp.net form using vb coding?

Q2: can i create sql table which store binary(image url) data direct?

thank you

Save Clipboard image as an attachment?


Does anyone know of a solution to save a clipboard image as an attachment (jpg) to a New Form? Basically the ability to save screenshots as an attachment.


ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend