---
title: "oneimage cookbook"
url: https://recursiveai.org/oneimage/cookbook/
description: "Answers to common image tasks in C#. Each recipe is a complete program you can run on a real image, with the output it really prints."
version: "1.10.4"
---

# oneimage cookbook

Answers to common image tasks in C#. Each recipe is a complete program you can run on a real image, with the output it really prints.

## Resize and crop

- [Resize an image in C#](https://recursiveai.org/oneimage/cookbook/resize-image/index.md): Resize an image in C# and keep the aspect ratio: to a width, into a box, cropped to fill or padded, at the quality you choose. Runnable code with OneImage, on any OS.
- [Create a thumbnail in C#](https://recursiveai.org/oneimage/cookbook/create-thumbnail/index.md): Create a thumbnail in C# in one call: upright, never enlarged, sRGB, with EXIF and GPS removed, as JPEG or WebP, or a square that fills the box. Runnable code with OneImage.
- [Crop an image in C#](https://recursiveai.org/oneimage/cookbook/crop-image/index.md): Crop an image in C#: a rectangle, a centered square, or a fixed aspect ratio with a chosen focus, in upright coordinates. Runnable code with OneImage, on any OS.
- [Rotate or flip an image in C#](https://recursiveai.org/oneimage/cookbook/rotate-flip-image/index.md): Rotate an image 90 or 180 degrees, by any angle, or flip it horizontally or vertically in C#. Runnable code with OneImage, on any OS.
- [Fix EXIF orientation in C#](https://recursiveai.org/oneimage/cookbook/fix-exif-orientation/index.md): Phone photos come out sideways in C# because the EXIF orientation tag isn’t applied. Load them upright, save them upright, and what the eight orientation values mean. Runnable code with OneImage.
- [Resize an animated GIF in C#](https://recursiveai.org/oneimage/cookbook/resize-animated-gif/index.md): Resize an animated GIF in C# and keep every frame, its delay and the loop setting. Read the frame count, make a still preview, or shrink the file as animated WebP. Runnable code with OneImage.

## Convert formats

- [Convert PNG to JPG in C#](https://recursiveai.org/oneimage/cookbook/convert-png-to-jpg/index.md): Convert PNG to JPG in C#, keeping transparent areas white, and JPG to PNG, BMP, TIFF, GIF or ICO: the file extension picks the format. Runnable code with OneImage, on any OS.
- [Convert an image to WebP in C#](https://recursiveai.org/oneimage/cookbook/convert-to-webp/index.md): Convert JPG, PNG or GIF to WebP in C# with one line of pure .NET code, no native libwebp: quality, lossless and animated WebP. Runnable code with OneImage.
- [Convert SVG to PNG in C#](https://recursiveai.org/oneimage/cookbook/svg-to-png/index.md): Convert SVG to PNG in C# at any size, drawn sharp rather than scaled up, with no Skia or System.Drawing: files, SVG strings and text with your own fonts. Runnable code with OneImage.Svg.
- [Convert a PDF to an image in C#](https://recursiveai.org/oneimage/cookbook/pdf-to-image/index.md): Convert PDF pages to PNG or JPG in C# with pure .NET code, no PDFium or Ghostscript: every page, one page at 300 dpi, or a thumbnail. Runnable code with OneImage.Pdf.
- [Convert a PDF to TIFF in C#](https://recursiveai.org/oneimage/cookbook/pdf-to-tiff/index.md): Convert a PDF to a multipage TIFF in C# with pure .NET code: every page or a range, 300 dpi, gray or black and white for archives and fax. Runnable code with OneImage.Pdf.
- [Convert PSD to PNG in C#](https://recursiveai.org/oneimage/cookbook/psd-to-png/index.md): Convert a Photoshop PSD or PSB file to PNG, JPG or WebP in C# without Photoshop or ImageMagick, and export each layer as a PNG. Runnable code with OneImage.Psd.
- [Split a multipage TIFF in C#](https://recursiveai.org/oneimage/cookbook/split-multipage-tiff/index.md): Split a multipage TIFF in C# into single-page files or PNGs, count its pages without decoding, and recompress it, including fax TIFFs. Runnable code with OneImage.

## Edit and compress

- [Compress an image in C#](https://recursiveai.org/oneimage/cookbook/compress-image/index.md): Compress an image in C# to reduce its file size: JPEG quality, resizing first, WebP, lossless PNG and WebP, and compressing a JPEG to a target size in KB. Runnable code with OneImage.
- [Convert an image to grayscale in C#](https://recursiveai.org/oneimage/cookbook/convert-to-grayscale/index.md): Convert an image to grayscale in C# with one call, with correct luminance, as a true 8-bit gray file, or to pure black and white. Runnable code with OneImage, on any OS.
- [Add a watermark to an image in C#](https://recursiveai.org/oneimage/cookbook/add-watermark/index.md): Add a watermark to an image in C#: a logo with opacity in a corner, or a tiled, diagonal text watermark across the photo. Runnable code with OneImage, on any OS.
- [Draw text on an image in C#](https://recursiveai.org/oneimage/cookbook/draw-text-on-image/index.md): Draw text on an image in C# with a real font: position, alignment, wrapping, a background box and an outline. Runnable code with OneImage.Text, on any OS.

## Image info and metadata

- [Get image dimensions in C#](https://recursiveai.org/oneimage/cookbook/get-image-size/index.md): Get an image’s width, height and format in C# without loading it: read only the headers of a JPEG, PNG, GIF, WebP or TIFF, and get the displayed size of phone photos. Runnable code with OneImage.
- [Read EXIF data in C#](https://recursiveai.org/oneimage/cookbook/read-exif-data/index.md): Read EXIF data from a photo in C#: camera make and model, date taken, orientation and the GPS position, from the headers only. Runnable code with OneImage, on any OS.
- [Remove EXIF metadata from an image in C#](https://recursiveai.org/oneimage/cookbook/remove-exif-metadata/index.md): Remove EXIF data, including the GPS location, from photos in C# before you publish them, keeping the photo upright and its colors right. Runnable code with OneImage.

## ASP.NET Core

- [Resize images on the fly in ASP.NET Core](https://recursiveai.org/oneimage/cookbook/resize-images-aspnet-core/index.md): Resize, crop and convert images on request in ASP.NET Core with URLs like photo.jpg?width=400: middleware with a disk cache, presets and signed URLs. Runnable code with OneImage.Web.
- [Resize uploaded images in ASP.NET Core](https://recursiveai.org/oneimage/cookbook/resize-uploaded-images-aspnet-core/index.md): Resize uploaded images in ASP.NET Core: an endpoint that stores every upload upright, at most 1600 px wide, as WebP without GPS data, and crops a user-picked square. Runnable code with OneImage.
