Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
kamsar committed Jul 18, 2014
0 parents commit 9df9b47
Show file tree
Hide file tree
Showing 23 changed files with 1,103 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
######## GENERAL IGNORES #######

# ignore logs, OS cache files
*.log
.DS_Store*
ehthumbs.db
Icon?
Thumbs.db

######## GENERAL .NET IGNORES ########

# Ignore binaries in the source
src/*/bin
src/*/obj
lib/sitecore/*

# Ignore user-scoped solution and project settings
*.user
*.suo

# NuGet packages
packages/*
!packages/repositories.config
Build/*.nupkg
22 changes: 22 additions & 0 deletions Dianoga.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.30501.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dianoga", "src\Dianoga\Dianoga.csproj", "{FD53D6C4-00CC-4CD0-8B18-98D0DD97C289}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{FD53D6C4-00CC-4CD0-8B18-98D0DD97C289}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FD53D6C4-00CC-4CD0-8B18-98D0DD97C289}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FD53D6C4-00CC-4CD0-8B18-98D0DD97C289}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FD53D6C4-00CC-4CD0-8B18-98D0DD97C289}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
5 changes: 5 additions & 0 deletions build/Build NuGet.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

@echo off
"%~dp0..\tools\nuget.exe" restore "%~dp0..\Dianoga.sln"
"%~dp0..\tools\nuget.exe" pack "%~dp0..\src\Dianoga\Dianoga.csproj" -Build -Symbols -Properties Configuration=Release
PAUSE
9 changes: 9 additions & 0 deletions license.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
THE MIT LICENSE

Copyright (c) 2014 ISITE Design/Kam Figy

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
502 changes: 502 additions & 0 deletions src/Dianoga/Dianoga Tools/PNGOptimizer/License.txt

Large diffs are not rendered by default.

Binary file not shown.
84 changes: 84 additions & 0 deletions src/Dianoga/Dianoga Tools/PNGOptimizer/PngOptimizerDll.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/////////////////////////////////////////////////////////////////////////////////////
// PngOptimizerDll - A DLL to get access to PngOptimizer optimization engine
// Copyright (C) 2012/2013 Hadrien Nilsson - psydk.org
// This DLL is distributed under the terms of the GNU LESSER GENERAL PUBLIC LICENSE
// See License.txt for the full license.
/////////////////////////////////////////////////////////////////////////////////////
#ifndef PNGOPTIMIZERDLL_H
#define PNGOPTIMIZERDLL_H

// Version: 2.4.0

#ifndef PNGOPTIMIZERDLL_IMPL
#define PNGOPTIMIZERDLL_API extern "C" __declspec(dllimport)
#else
#define PNGOPTIMIZERDLL_API extern "C" __declspec(dllexport)
#endif

// Remarks
// - Windows types like BOOL are used for better C# integration.
// - Allocated strings in PO_GetSettings and PO_GetLastErrorString.
// should be freed with CoTaskMemFree(). This is automatically done when
// unmarshalling with C#. Check TestPODll for an example.
// - The API is to be accessed by one thread at a time. A thread attempting
// to call the API will be blocked if another thread is alreay calling.

enum
{
POChunkOption_Remove = 0, // PNG chunk will be removed unconditionally
POChunkOption_Keep = 1, // PNG chunk will be kept if it is found
POChunkOption_Force = 2 // PNG chunk will be modified or added if not found
};

struct POSettings
{
BOOL BackupOldPngFiles; // Creates a backup (default: TRUE)
BOOL KeepInterlacing; // Keeps interlacing if present (default: FALSE)
BOOL IE6Compatible; // Avoids some types of PNG that do not work on IE6 (default: FALSE)
BOOL SkipAnimatedGifs; // Avoids converting a GIF if it is animated (default: FALSE)
BOOL KeepFileDate; // Keeps the date of the original file (default: FALSE)

DWORD BkgdOption; // POChunkOption (default: Remove)
DWORD BkgdColor; // Forced color. 0xAARRGGBB (default: 0xFF000000)

DWORD TextOption; // POChunkOption (default: Remove)
PCWCH TextKeyword; // Forced text keyword (default: "")
PCWCH TextData; // Forced text data (default: "")

DWORD PhysOption; // POChunkOption (default: Remove)
DWORD PhysPpmX; // Forced pixels per meter X (default: 2834)
DWORD PhysPpmY; // Forced pixels per meter Y (default: 2834)
};

// Optimizes one PNG or APNG file. If the file is a GIF/BMP/TGA, it is converted to PNG.
// [in] filePath Path of the file to optimize or convert
// [ret] TRUE upon success
PNGOPTIMIZERDLL_API BOOL PO_OptimizeFile(PCWCH filePath);

// Optimizes one PNG or APNG file loaded in memory. If the file is a GIF/BMP/TGA, it is
// converted to PNG.
// [in] image File content to optimize/convert
// [in] imageSize Size in bytes of the file content to optimize/convert
// [out] result Result buffer. To be allocated by the caller.
// [in] resultCapacity Capacity in bytes of the result buffer
// [out] pResultSize Size in bytes of the result
// [ret] TRUE upon success
PNGOPTIMIZERDLL_API BOOL PO_OptimizeFileMem(LPCVOID* image, INT imageSize,
LPVOID* result, INT resultCapacity, INT* pResultSize);

// Gets a description of the error when PO_OptimizeFile returns FALSE.
// [ret] Last error description. Free the string with CoTaskMemFree() after usage.
PNGOPTIMIZERDLL_API PCWCH PO_GetLastErrorString();

// Sets the settings used when optimizing with PO_OptimizeFile.
// [in] s Settings structure to copy from
// [ret] TRUE upon success
PNGOPTIMIZERDLL_API BOOL PO_SetSettings(const POSettings* s);

// Gets the settings used when optimizing with PO_OptimizeFile.
// [out] s Settings structure receiving the settings. Strings should be
// freed with CoTaskMemFree() after usage.
// [ret] TRUE upon success
PNGOPTIMIZERDLL_API BOOL PO_GetSettings(POSettings* s);

#endif
Binary file not shown.
Binary file added src/Dianoga/Dianoga Tools/libjpeg/jpeg62.dll
Binary file not shown.
Binary file added src/Dianoga/Dianoga Tools/libjpeg/jpegtran.exe
Binary file not shown.
71 changes: 71 additions & 0 deletions src/Dianoga/Dianoga Tools/libjpeg/license.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
The authors make NO WARRANTY or representation, either express or implied,
with respect to this software, its quality, accuracy, merchantability, or
fitness for a particular purpose. This software is provided "AS IS", and you,
its user, assume the entire risk as to its quality and accuracy.

This software is copyright (C) 1991-1998, Thomas G. Lane.
All Rights Reserved except as specified below.

Permission is hereby granted to use, copy, modify, and distribute this
software (or portions thereof) for any purpose, without fee, subject to these
conditions:
(1) If any part of the source code for this software is distributed, then this
README file must be included, with this copyright and no-warranty notice
unaltered; and any additions, deletions, or changes to the original files
must be clearly indicated in accompanying documentation.
(2) If only executable code is distributed, then the accompanying
documentation must state that "this software is based in part on the work of
the Independent JPEG Group".
(3) Permission for use of this software is granted only if the user accepts
full responsibility for any undesirable consequences; the authors accept
NO LIABILITY for damages of any kind.

These conditions apply to any software derived from or based on the IJG code,
not just to the unmodified library. If you use our work, you ought to
acknowledge us.

Permission is NOT granted for the use of any IJG author's name or company name
in advertising or publicity relating to this software or products derived from
it. This software may be referred to only as "the Independent JPEG Group's
software".

We specifically permit and encourage the use of this software as the basis of
commercial products, provided that all warranty or liability claims are
assumed by the product vendor.


ansi2knr.c is included in this distribution by permission of L. Peter Deutsch,
sole proprietor of its copyright holder, Aladdin Enterprises of Menlo Park, CA.
ansi2knr.c is NOT covered by the above copyright and conditions, but instead
by the usual distribution terms of the Free Software Foundation; principally,
that you must include source code if you redistribute it. (See the file
ansi2knr.c for full details.) However, since ansi2knr.c is not needed as part
of any program generated from the IJG code, this does not limit you more than
the foregoing paragraphs do.

The Unix configuration script "configure" was produced with GNU Autoconf.
It is copyright by the Free Software Foundation but is freely distributable.
The same holds for its supporting scripts (config.guess, config.sub,
ltconfig, ltmain.sh). Another support script, install-sh, is copyright
by M.I.T. but is also freely distributable.

It appears that the arithmetic coding option of the JPEG spec is covered by
patents owned by IBM, AT&T, and Mitsubishi. Hence arithmetic coding cannot
legally be used without obtaining one or more licenses. For this reason,
support for arithmetic coding has been removed from the free JPEG software.
(Since arithmetic coding provides only a marginal gain over the unpatented
Huffman mode, it is unlikely that very many implementations will support it.)
So far as we are aware, there are no patent restrictions on the remaining
code.

The IJG distribution formerly included code to read and write GIF files.
To avoid entanglement with the Unisys LZW patent, GIF reading support has
been removed altogether, and the GIF writer has been simplified to produce
"uncompressed GIFs". This technique does not use the LZW algorithm; the
resulting GIF files are larger than usual, but are readable by all standard
GIF decoders.

We are required to state that
"The Graphics Interchange Format(c) is the Copyright property of
CompuServe Incorporated. GIF(sm) is a Service Mark property of
CompuServe Incorporated."
22 changes: 22 additions & 0 deletions src/Dianoga/Dianoga.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!--
Dianoga image optimization framework configuration
Automatically optimizes Sitecore media library images before sending them to the client,
including if they have been resized by Sitecore
-->
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<pipelines>
<getMediaStream>
<processor type="Dianoga.OptimizeImage, Dianoga" />
</getMediaStream>
</pipelines>

<settings>
<!--
The default resizing quality for JPEGs is extremely high (95) which wastes bandwidth.
Community recommendations place the optimal JPEG quality/size ratio between 70 and 80.
-->
<setting name="Media.Resizing.Quality" value="72" />
</settings>
</sitecore>
</configuration>
71 changes: 71 additions & 0 deletions src/Dianoga/Dianoga.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{FD53D6C4-00CC-4CD0-8B18-98D0DD97C289}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Dianoga</RootNamespace>
<AssemblyName>Dianoga</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</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="Sitecore.Kernel">
<HintPath>..\..\lib\sitecore\Sitecore.Kernel.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Web" />
</ItemGroup>
<ItemGroup>
<Compile Include="IImageOptimizer.cs" />
<Compile Include="IOptimizerResult.cs" />
<Compile Include="Jpeg\JpegOptimizer.cs" />
<Compile Include="Jpeg\JpegOptimizerResult.cs" />
<Compile Include="OptimizeImage.cs" />
<Compile Include="Png\PngOptimizer.cs" />
<Compile Include="Png\PngOptimizerResult.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="Dianoga Tools\libjpeg\jpeg62.dll" />
<Content Include="Dianoga Tools\libjpeg\jpegtran.exe" />
<Content Include="Dianoga Tools\libjpeg\license.txt" />
<Content Include="Dianoga Tools\PNGOptimizer\License.txt" />
<Content Include="Dianoga Tools\PNGOptimizer\PngOptimizerDll.dll" />
<Content Include="Dianoga Tools\PNGOptimizer\PngOptimizerDll.h" />
</ItemGroup>
<ItemGroup>
<None Include="Dianoga.config" />
<None Include="Dianoga Tools\PNGOptimizer\PngOptimizerDll.lib" />
<None Include="Dianoga.nuspec" />
</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>
21 changes: 21 additions & 0 deletions src/Dianoga/Dianoga.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0"?>
<package>
<metadata>
<id>Dianoga</id>
<version>1.0.0-beta01</version>
<title>Dianoga</title>
<authors>Kam Figy</authors>
<owners>Kam Figy, ISITE Design</owners>
<licenseUrl>http://opensource.org/licenses/MIT</licenseUrl>
<projectUrl>http://github.com/kamsar/Dianoga</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Automatic media library image file optimization for Sitecore</description>
<releaseNotes>Initial release</releaseNotes>
<copyright>Copyright 2014</copyright>
<tags>sitecore optimization</tags>
</metadata>
<files>
<file src="Dianoga.config" target="content\App_Config\Include" />
<file src="Dianoga Tools\*" target="content\Dianoga Tools" />
</files>
</package>
7 changes: 7 additions & 0 deletions src/Dianoga/IImageOptimizer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Dianoga
{
public interface IImageOptimizer
{
IOptimizerResult Optimize();
}
}
14 changes: 14 additions & 0 deletions src/Dianoga/IOptimizerResult.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System.IO;

namespace Dianoga
{
public interface IOptimizerResult
{
bool Success { get; }
string ErrorMessage { get; }
int SizeBefore { get; }
int SizeAfter { get; }

Stream CreateResultStream();
}
}
Loading

0 comments on commit 9df9b47

Please sign in to comment.