none
resizing clipping path RRS feed

  • 質問

  • I have a issue with keeping my clipping path in a image, when i resize it.

     

    is this actually posible at all ?

     

    i figure i shouldt use the GraphicsPath class. and the SetClip method. But can't figure out how to extract and resize the clipping paths from the originale image.

     

    Any suggestions.

     

    2007年8月13日 10:02

回答

  • Okay, I did a bit of research on this.  Adobe Photoshop apparently is able to store a clipping path in the metadata of a JPEG or TIFF.  This is a non-standard extension, GDI+ can neither access this metadata nor correctly reproduce it.  You'll need a commercial image processing library to get close, LeadTools is the usual selection.  Before you purchase, contact the vendor to make sure they can encode and decode the clipping path.  Good luck.
    2007年8月14日 13:07
    モデレータ
  • I'm surprised that the clipping path was saved in the JPEG that wasn't resized.  If this:

    Code Snippet

    Image MyImage = Image.FromFile(inputFile);

    BitMap myExportImage = new Bitmap(MyImage,new Size(intNewWidth,intnewwidth));

    myExportImage.Save(outputFileName, System.Drawing.Imaging.ImageFormat.Jpeg);

     

     doesn't resize and save the clipping path, then you will have to retrieve and save the clipping path programmatically.  ImageMagick appears to have good support for clipping paths.

    2007年8月14日 14:43

すべての返信

  • Use the Graphics.ScaleTransform() method to get your image to resize, then adjust your path with GraphicsPath.Transform(), using the  Graphics.Transform property.  Then call Graphics.SetClip() and draw the image.  Admittedly, I haven't tried it. Ought to work though.
    2007年8月13日 17:34
    モデレータ

  • This to me looks like the way i want to go. But i havn't figured out how to get the clippingPath from the original Image.

    something like :

    GraphicsPath myPath = myImage.<GetImageClippingPath>();


    2007年8月14日 6:57
  • I couldn't begin to guess how you want you image to be clipped.  What are your requirements?
    2007年8月14日 7:56
    モデレータ
  • The primary goal of this task is to take an image, resize it, at keeping the clipping path embedded in the Originale image.

    step 2. wouldt be to crop it. Not quiet sure if step 2, is actually possible.



    2007年8月14日 8:17
  • A clipping path embedded in an image?  Never heard of that.  Certainly not something that's supported by GDI+.  Do you know how to get it out and put it back in?  
    2007年8月14日 10:18
    モデレータ
  •  

    It's common use in the Graphical Industries. For instance having a Image of an produkt, you can a clipping path to the image. The image doesn't get clipped, but the path is embedded in the image, for future use. For instance when you want to create a catalog.

     

    And no. I don't know how to get it out and back in. Hence this thread.

     

    The thing i discovered after some testing is :

     

    if i Scale the image by doing this.

     

    Image MyImage = Image.FromFile(inputFile);

    BitMap myExportImage = new Bitmap( intNewWidth, intNewHeight);

    Graphics myGraph = Graphics.FromImage(myExportImage);

     

    myGraph.DrawImage(MyImage,0,0, intNewWidth, intNewHeight);

    myExportImage.Save( outputFileName, System.Drawing.Imaging.ImageFormat.Jpeg);

     

    the image is scaled but the clippingPath is gone.

    If i instead do this :

     

    Image MyImage = Image.FromFile(inputFile);

     

    Graphics myGraph = Graphics.FromImage(MyImage);

     

    myGraph.ScaleTransform( intNewWidth,intNewHeight);

     

    MyImage.Save( outputFileName, System.Drawing.Imaging.ImageFormat.Jpeg);

     

    The Image isn't scaled, but the Clipping Path is intact.

     

    Isn't there a way of scaleing an image without using the Bitmap class and the getThumbNail method from the Image-Class?

     

     

     

     

    2007年8月14日 11:12
  • What is the format (file type?, extension?) of the inputFile?

    What happens when you resize the saved Jpeg?  That is, what happens when you do this:

    Code Snippet

    Image MyImage = Image.FromFile(inputFile);

    MyImage.Save(outputFileName, System.Drawing.Imaging.ImageFormat.Jpeg);

    MyImage = Image.FromFile(outputFileName);

    BitMap myExportImage = new Bitmap(intNewWidth, intNewHeight);

    Graphics myGraph = Graphics.FromImage(myExportImage);

    myGraph.DrawImage(MyImage, 0, 0, intNewWidth, intNewHeight);

    myExportImage.Save(outputFileName, System.Drawing.Imaging.ImageFormat.Jpeg);

     

     

     

    2007年8月14日 12:02
  • Tried with your code.. Still no clipping path in the resulting image.

     

    the file Input will be jpeg's and tiff's.

    2007年8月14日 12:21
  • You say that when you save the original file to a JPEG image it has a clipping path?  I don't understand how that is possible.  That's why I asked you to resize that image.  Does the original image have a vector clipping path or an embedded Alpha path.

    2007年8月14日 12:52
  • Okay, I did a bit of research on this.  Adobe Photoshop apparently is able to store a clipping path in the metadata of a JPEG or TIFF.  This is a non-standard extension, GDI+ can neither access this metadata nor correctly reproduce it.  You'll need a commercial image processing library to get close, LeadTools is the usual selection.  Before you purchase, contact the vendor to make sure they can encode and decode the clipping path.  Good luck.
    2007年8月14日 13:07
    モデレータ
  • Actually i need both.

     

    But for starters, we need the vector clipping path. For instanced generated with Adobe PhotoShop.

     

     

    2007年8月14日 13:15
  • hey Nobugs.

     

    Ok if PhotoShop clipping paths aren't suported in the GDI+. This thread is almost done.

     

    Thanks for the input, and research.

     

    i'll just wait for John and see what he's saying.

     

     

    2007年8月14日 13:19
  • I'm surprised that the clipping path was saved in the JPEG that wasn't resized.  If this:

    Code Snippet

    Image MyImage = Image.FromFile(inputFile);

    BitMap myExportImage = new Bitmap(MyImage,new Size(intNewWidth,intnewwidth));

    myExportImage.Save(outputFileName, System.Drawing.Imaging.ImageFormat.Jpeg);

     

     doesn't resize and save the clipping path, then you will have to retrieve and save the clipping path programmatically.  ImageMagick appears to have good support for clipping paths.

    2007年8月14日 14:43
  • If you really want to resize your image but you do not know how to use Photoshop then some easy step will make your image professional looking. If you are not able to do them then Clipping Path Experts - Photoshop Clipping Path Service would be best for you.

    I think paint is one of the best way to resize image without Photoshop. Here is some easy step that will help to resize without loose image quality.


    I hope you people could resize your image without loose image quality. Thanks a lot to keep in touch with us.

    If you want to more information about image resize .I think this site best for you

    https://backgroundremovalservices.com/resize-image-without-losing-quality/

    2019年5月7日 6:13