ByteScout Watermarking SDK - C# - Resize Image as Fit Within - ByteScout

ByteScout Watermarking SDK – C# – Resize Image as Fit Within

  • Home
  • /
  • Articles
  • /
  • ByteScout Watermarking SDK – C# – Resize Image as Fit Within

resize image as fit within in C# and ByteScout Watermarking SDK

resize image as fit within in C#

These source code samples are listed and grouped by their programming language and functions they use. ByteScout Watermarking SDK was made to help with resize image as fit within in C#. ByteScout Watermarking SDK is the software development kit that helps to quickly implement adding of watermarks on top of PNG, JPG, BMP images as well as on multipaged TIFF files. You may select ready to use presets or create your own preset with semitransparent logo images, text lines with adjustable font size, family, color, rotation.

Fast application programming interfaces of ByteScout Watermarking SDK for C# plus the instruction and the C# code below will help you quickly learn resize image as fit within. To do resize image as fit within in your C# project or application you may simply copy & paste the code and then run your app! Further enhancement of the code will make it more vigorous.

On our website you may get trial version of ByteScout Watermarking SDK for free. Source code samples are included to help you with your C# application.

Try it today: Get 60 Day Free Trial or sign up for Web API

Fit within resize.VS2005.csproj
      
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProductVersion>8.0.50727</ProductVersion> <SchemaVersion>2.0</SchemaVersion> <ProjectGuid>{75A2CDE7-8F28-48B4-BF4B-0569FF30E043}</ProjectGuid> <OutputType>Exe</OutputType> <AppDesignerFolder>Properties</AppDesignerFolder> <RootNamespace>Fit_within_resize</RootNamespace> <AssemblyName>Fit within resize</AssemblyName> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <Optimize>false</Optimize> <OutputPath>bin\Debug\</OutputPath> <DefineConstants>DEBUG;TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>pdbonly</DebugType> <Optimize>true</Optimize> <OutputPath>bin\Release\</OutputPath> <DefineConstants>TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> </PropertyGroup> <ItemGroup> <Reference Include="Bytescout.Watermarking, Version=1.5.3.0, Culture=neutral, PublicKeyToken=f7dd1bd9d40a50eb, processorArchitecture=MSIL"> <SpecificVersion>False</SpecificVersion> </Reference> <Reference Include="System" /> <Reference Include="System.Data" /> <Reference Include="System.Drawing" /> <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> <Compile Include="Program.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. <Target Name="BeforeBuild"> </Target> <Target Name="AfterBuild"> </Target> --> </Project>

Try it today: Get 60 Day Free Trial or sign up for Web API

Fit within resize.VS2005.sln
      
Microsoft Visual Studio Solution File, Format Version 9.00 # Visual Studio 2005 # SharpDevelop 2.2.1.2648 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Fit within resize","Fit within resize.VS2005.csproj", "{75A2CDE7-8F28-48B4-BF4B-0569FF30E043}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {75A2CDE7-8F28-48B4-BF4B-0569FF30E043}.Debug|Any CPU.Build.0 = Debug|Any CPU {75A2CDE7-8F28-48B4-BF4B-0569FF30E043}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {75A2CDE7-8F28-48B4-BF4B-0569FF30E043}.Release|Any CPU.Build.0 = Release|Any CPU {75A2CDE7-8F28-48B4-BF4B-0569FF30E043}.Release|Any CPU.ActiveCfg = Release|Any CPU EndGlobalSection EndGlobal

Try it today: Get 60 Day Free Trial or sign up for Web API

Fit within resize.VS2008.csproj
      
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5"> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProductVersion>9.0.21022</ProductVersion> <SchemaVersion>2.0</SchemaVersion> <ProjectGuid>{75A2CDE7-8F28-48B4-BF4B-0569FF30E043}</ProjectGuid> <OutputType>Exe</OutputType> <AppDesignerFolder>Properties</AppDesignerFolder> <RootNamespace>Fit_within_resize</RootNamespace> <AssemblyName>Fit within resize</AssemblyName> <OldToolsVersion>2.0</OldToolsVersion> <TargetFrameworkVersion>v3.5</TargetFrameworkVersion> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <Optimize>false</Optimize> <OutputPath>bin\Debug\</OutputPath> <DefineConstants>DEBUG;TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>pdbonly</DebugType> <Optimize>true</Optimize> <OutputPath>bin\Release\</OutputPath> <DefineConstants>TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> </PropertyGroup> <ItemGroup> <Reference Include="Bytescout.Watermarking, Version=1.5.3.0, Culture=neutral, PublicKeyToken=f7dd1bd9d40a50eb, processorArchitecture=MSIL"> <SpecificVersion>False</SpecificVersion> </Reference> <Reference Include="System" /> <Reference Include="System.Data" /> <Reference Include="System.Drawing" /> <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> <Compile Include="Program.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. <Target Name="BeforeBuild"> </Target> <Target Name="AfterBuild"> </Target> --> </Project>

Try it today: Get 60 Day Free Trial or sign up for Web API

Fit within resize.VS2008.sln
      
Microsoft Visual Studio Solution File, Format Version 10.00 # Visual Studio 2008 # SharpDevelop 2.2.1.2648 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Fit within resize","Fit within resize.VS2008.csproj", "{75A2CDE7-8F28-48B4-BF4B-0569FF30E043}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {75A2CDE7-8F28-48B4-BF4B-0569FF30E043}.Debug|Any CPU.Build.0 = Debug|Any CPU {75A2CDE7-8F28-48B4-BF4B-0569FF30E043}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {75A2CDE7-8F28-48B4-BF4B-0569FF30E043}.Release|Any CPU.Build.0 = Release|Any CPU {75A2CDE7-8F28-48B4-BF4B-0569FF30E043}.Release|Any CPU.ActiveCfg = Release|Any CPU EndGlobalSection EndGlobal

Try it today: Get 60 Day Free Trial or sign up for Web API

Fit within resize.VS2010.csproj
      
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0"> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProductVersion> </ProductVersion> <SchemaVersion>2.0</SchemaVersion> <ProjectGuid>{75A2CDE7-8F28-48B4-BF4B-0569FF30E043}</ProjectGuid> <OutputType>Exe</OutputType> <AppDesignerFolder>Properties</AppDesignerFolder> <RootNamespace>Fit_within_resize</RootNamespace> <AssemblyName>Fit within resize</AssemblyName> <OldToolsVersion>3.5</OldToolsVersion> <TargetFrameworkVersion>v4.0</TargetFrameworkVersion> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <Optimize>false</Optimize> <OutputPath>bin\Debug\</OutputPath> <DefineConstants>DEBUG;TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>pdbonly</DebugType> <Optimize>true</Optimize> <OutputPath>bin\Release\</OutputPath> <DefineConstants>TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> </PropertyGroup> <ItemGroup> <Reference Include="Bytescout.Watermarking, Version=1.5.3.0, Culture=neutral, PublicKeyToken=f7dd1bd9d40a50eb, processorArchitecture=MSIL"> <SpecificVersion>False</SpecificVersion> </Reference> <Reference Include="System" /> <Reference Include="System.Data" /> <Reference Include="System.Drawing" /> <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> <Compile Include="Program.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. <Target Name="BeforeBuild"> </Target> <Target Name="AfterBuild"> </Target> --> </Project>

Try it today: Get 60 Day Free Trial or sign up for Web API

Fit within resize.VS2010.sln
      
Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 # SharpDevelop 2.2.1.2648 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Fit within resize","Fit within resize.VS2010.csproj", "{75A2CDE7-8F28-48B4-BF4B-0569FF30E043}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {75A2CDE7-8F28-48B4-BF4B-0569FF30E043}.Debug|Any CPU.Build.0 = Debug|Any CPU {75A2CDE7-8F28-48B4-BF4B-0569FF30E043}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {75A2CDE7-8F28-48B4-BF4B-0569FF30E043}.Release|Any CPU.Build.0 = Release|Any CPU {75A2CDE7-8F28-48B4-BF4B-0569FF30E043}.Release|Any CPU.ActiveCfg = Release|Any CPU EndGlobalSection EndGlobal

Try it today: Get 60 Day Free Trial or sign up for Web API

Fit within resize.csproj
      
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProductVersion>8.0.50727</ProductVersion> <SchemaVersion>2.0</SchemaVersion> <ProjectGuid>{75A2CDE7-8F28-48B4-BF4B-0569FF30E043}</ProjectGuid> <OutputType>Exe</OutputType> <AppDesignerFolder>Properties</AppDesignerFolder> <RootNamespace>Fit_within_resize</RootNamespace> <AssemblyName>Fit within resize</AssemblyName> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <Optimize>false</Optimize> <OutputPath>bin\Debug\</OutputPath> <DefineConstants>DEBUG;TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>pdbonly</DebugType> <Optimize>true</Optimize> <OutputPath>bin\Release\</OutputPath> <DefineConstants>TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> </PropertyGroup> <ItemGroup> <Reference Include="Bytescout.Watermarking, Version=1.5.3.0, Culture=neutral, PublicKeyToken=f7dd1bd9d40a50eb, processorArchitecture=MSIL"> <SpecificVersion>False</SpecificVersion> </Reference> <Reference Include="System" /> <Reference Include="System.Data" /> <Reference Include="System.Drawing" /> <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> <Compile Include="Program.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. <Target Name="BeforeBuild"> </Target> <Target Name="AfterBuild"> </Target> --> </Project>

Try it today: Get 60 Day Free Trial or sign up for Web API

Fit within resize.sln
      
Microsoft Visual Studio Solution File, Format Version 9.00 # Visual Studio 2005 # SharpDevelop 2.2.1.2648 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Fit within resize", "Fit within resize.csproj", "{75A2CDE7-8F28-48B4-BF4B-0569FF30E043}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {75A2CDE7-8F28-48B4-BF4B-0569FF30E043}.Debug|Any CPU.Build.0 = Debug|Any CPU {75A2CDE7-8F28-48B4-BF4B-0569FF30E043}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {75A2CDE7-8F28-48B4-BF4B-0569FF30E043}.Release|Any CPU.Build.0 = Release|Any CPU {75A2CDE7-8F28-48B4-BF4B-0569FF30E043}.Release|Any CPU.ActiveCfg = Release|Any CPU EndGlobalSection EndGlobal

Try it today: Get 60 Day Free Trial or sign up for Web API

Program.cs
      
using System; using System.Diagnostics; using System.Drawing; using System.Collections.Generic; using Bytescout.Watermarking; using Bytescout.Watermarking.Presets; namespace Sample { class Program { static void Main(string[] args) { // Create Watermarker instance Watermarker waterMarker = new Watermarker(); // Initialize library waterMarker.InitLibrary("demo", "demo"); // Set input file name string inputFilePath = "my_sample_image.jpg"; // Set output file title string outputFilePath = "my_sample_output.jpg"; // Add image to apply watermarks to waterMarker.AddInputFile(inputFilePath, outputFilePath); // Allow resize waterMarker.OutputOptions.Resize = true; // Allow to enlarge image waterMarker.OutputOptions.DontEnlargeSmallImages = false; // Set resize type to pixels waterMarker.OutputOptions.ResizeType = ResizeType.Pixels; // Fit to width waterMarker.OutputOptions.ResizeFitWithin = FitWithin.WidthOnly; // Set width waterMarker.OutputOptions.ResizeWidthInPixels = 600; // Set height waterMarker.OutputOptions.ResizeHeightInPixels = 20; // Set output directory waterMarker.OutputOptions.OutputDirectory = "."; // Apply watermarks waterMarker.Execute(); // open generated image file in default image viewer installed in Windows Process.Start(outputFilePath); } } }

Try it today: Get 60 Day Free Trial or sign up for Web API

MORE INFORMATION

Get 60 Day Free Trial or Visit ByteScout Watermarking SDK page

Explore ByteScout Watermarking SDK documentation

WEB API VERSION

Sign Up for free Web API key

Explore Web API Documentation

Tutorials:

prev
next