<commit_before><cfscript>
component extends="org.lucee.cfml.test.LuceeTestCase" labels="image" {
	public void function testImageFormats() localmode="true" {
		var imgf = ImageFormats();

		expect( imgf ).toBeStruct();
		expect( imgf ).toHaveKey( "decoder" );
		expect( imgf ).toHaveKey( "encoder" );

		expect( imgf.encoder ).notToBeEmpty();
		expect( imgf.decoder ).notToBeEmpty();

		expect( imgf.decoder ).toInclude( "JPG" );
		expect( imgf.encoder ).toInclude( "PNG" );

		// LDEV-4080
		expect( imgf.decoder ).toBeTypeOf( "array" );
		expect( imgf.encoder ).toBeTypeOf( "array" );

		// expect( isObject( imgf.decoder ) ).toBeTrue(); // i.e. should be a cfml array
		// expect( isObject( imgf.encoder ) ).toBeTrue(); // i.e. should be a cfml array
	}

	private function doDynamicSuiteConfig() localmode=true {
		try {
			var imgFormats = evaluate("imageFormats( true )"); // v2, evaluate to bypass compile error with v1
		} catch (e){
			var imgFormats = imageFormats(); // v1
		}
		variables.writeImageFormats = {};
		variables.readImageFormats = {};
		if ( isArray( imgFormats.decoder ) ){ // imageFormats(true) returns with 2.0 by codec
			// v1
			for ( local.format in ImageFormats().encoder ){
				variables.writeImageFormats[ format ] = format;
			}
			for ( local.format in ImageFormats().decoder ){
				variables.readImageFormats[ format ] = format;
			}
		} else {
			// v2
			// remember, the extension still picks which codec itself, but we try every combination
			loop collection=imgFormats.encoder key="local.codec" value="local.formats" {
				for ( local.format in formats ){
					variables.writeImageFormats[ codec & "-" & format ] = format;
				}
			}
			loop collection=imgFormats.decoder key="local.codec" value="local.formats" {
				for ( local.format in formats ){
					variables.readImageFormatsCode[ codec & "-" & format ] = format;
					variables.readImageFormats[ format ] = format;
				}
			}
		}
		/*
		systemOutput("--------------", true);
		systemOutput( imgFormats, true);
		systemOutput( variables.readImageFormats, true);
		systemOutput( variables.writeImageFormats, true);
		systemOutput("--------------", true);
		*/
	}

	function run( testResults, testBox ) localmode=true{
		doDynamicSuiteConfig();
		variables.testImage = imageNew( "", 100, 100, "rgb", "yellow" );

		loop collection=variables.writeImageFormats key="name" value="_imageFormat" {
			systemOutput(name & " " & _imageFormat, true);
			describe("test image format: [#name#]", function(){
				it( title="test imageWrite() with format: [#name#], ",
						data={ imageFormat=_imageFormat },
						body=function( data ) {
					try {
						var imageFormat = data.imageFormat;
						// test if we can write a file in this image format (image format is based on file extension )
						var testFile = getTempFile( getTempDirectory(), "image-write-test", imageFormat );

						expect(function(){
							imageWrite ( variables.testImage, testFile );
						}).notToThrow();
					} finally {
						if ( fileExists( testFile ) )
							fileDelete( testFile );
					}
				});

				it( title="test isImageFile() with format: [#name#]",
						data={ imageFormat=_imageFormat },
						body=function( data ) {
					try {
						var imageFormat = data.imageFormat;
						// test if we can write a file in this image format (image format is based on file extension )
						var testFile = getTempFile( getTempDirectory(), "image-write-test", imageFormat );
						imageWrite ( variables.testImage, testFile );

						expect( isImageFile( testFile ) ).toBeTrue( "Can write an image with the format [#imageFormat#]" );
					} finally {
						if ( fileExists( testFile ) )
							fileDelete( testFile );
					}
				});

				it( title="test imageRead() with format: [#name#]",
						data={ imageFormat=_imageFormat },
						body=function( data ) {
					try {
						var imageFormat = data.imageFormat;
						// test if we can write a file in this image format (image format is based on file extension )
						var testFile = getTempFile( getTempDirectory(), "image-write-test", imageFormat );<commit_msg>add imageInfo() and  ImageGetExifMetaData() tests with ImageFormats<commit_after><cfscript>
component extends="org.lucee.cfml.test.LuceeTestCase" labels="image" {
	public void function testImageFormats() localmode="true" {
		var imgf = ImageFormats();

		expect( imgf ).toBeStruct();
		expect( imgf ).toHaveKey( "decoder" );
		expect( imgf ).toHaveKey( "encoder" );

		expect( imgf.encoder ).notToBeEmpty();
		expect( imgf.decoder ).notToBeEmpty();

		expect( imgf.decoder ).toInclude( "JPG" );
		expect( imgf.encoder ).toInclude( "PNG" );

		// LDEV-4080
		expect( imgf.decoder ).toBeTypeOf( "array" );
		expect( imgf.encoder ).toBeTypeOf( "array" );

		// expect( isObject( imgf.decoder ) ).toBeTrue(); // i.e. should be a cfml array
		// expect( isObject( imgf.encoder ) ).toBeTrue(); // i.e. should be a cfml array
	}

	private function doDynamicSuiteConfig() localmode=true {
		try {
			var imgFormats = evaluate("imageFormats( true )"); // v2, evaluate to bypass compile error with v1
		} catch (e){
			var imgFormats = imageFormats(); // v1
		}
		variables.writeImageFormats = {};
		variables.readImageFormats = {};
		if ( isArray( imgFormats.decoder ) ){ // imageFormats(true) returns with 2.0 by codec
			// v1
			for ( local.format in ImageFormats().encoder ){
				variables.writeImageFormats[ format ] = format;
			}
			for ( local.format in ImageFormats().decoder ){
				variables.readImageFormats[ format ] = format;
			}
		} else {
			// v2
			// remember, the extension still picks which codec itself, but we try every combination
			loop collection=imgFormats.encoder key="local.codec" value="local.formats" {
				for ( local.format in formats ){
					variables.writeImageFormats[ codec & "-" & format ] = format;
				}
			}
			loop collection=imgFormats.decoder key="local.codec" value="local.formats" {
				for ( local.format in formats ){
					variables.readImageFormatsCode[ codec & "-" & format ] = format;
					variables.readImageFormats[ format ] = format;
				}
			}
		}
		/*
		systemOutput("--------------", true);
		systemOutput( imgFormats, true);
		systemOutput( variables.readImageFormats, true);
		systemOutput( variables.writeImageFormats, true);
		systemOutput("--------------", true);
		*/
	}

	function run( testResults, testBox ) localmode=true{
		doDynamicSuiteConfig();
		variables.testImage = imageNew( "", 100, 100, "rgb", "yellow" );

		loop collection=variables.writeImageFormats key="name" value="_imageFormat" {
			systemOutput(name & " " & _imageFormat, true);
			describe("test image format: [#name#]", function(){
				it( title="test imageWrite() with format: [#name#], ",
						data={ imageFormat=_imageFormat },
						body=function( data ) {
					try {
						var imageFormat = data.imageFormat;
						// test if we can write a file in this image format (image format is based on file extension )
						var testFile = getTempFile( getTempDirectory(), "image-write-test", imageFormat );

						expect(function(){
							imageWrite ( variables.testImage, testFile );
						}).notToThrow();
					} finally {
						if ( fileExists( testFile ) )
							fileDelete( testFile );
					}
				});

				it( title="test isImageFile() with format: [#name#]",
						data={ imageFormat=_imageFormat },
						body=function( data ) {
					try {
						var imageFormat = data.imageFormat;
						// test if we can write a file in this image format (image format is based on file extension )
						var testFile = getTempFile( getTempDirectory(), "image-write-test", imageFormat );
						imageWrite ( variables.testImage, testFile );

						expect( isImageFile( testFile ) ).toBeTrue( "Can write an image with the format [#imageFormat#]" );
					} finally {
						if ( fileExists( testFile ) )
							fileDelete( testFile );
					}
				});

				it( title="test imageInfo() with format: [#name#]",
						data={ imageFormat=_imageFormat },
						body=function( data ) {
					try {
						var imageFormat = data.imageFormat;
						// test if we can write a file in this image format (image format is based on file extension )
						var testFile = getTempFile( getTempDirectory(), "image-info-test", imageFormat );
						imageWrite ( variables.testImage, testFile );

						expect( imageInfo( testFile ) ).toBeStruct( "Can read ImageInfo with the format [#imageFormat#]" );
					} finally {
						if ( fileExists( testFile ) )
							fileDelete( testFile );
					}
				});

				it( title="test ImageGetExifMetaData() with format: [#name#]",
						data={ imageFormat=_imageFormat },
						body=function( data ) {
					try {
						var imageFormat = data.imageFormat;
						// test if we can write a file in this image format (image format is based on file extension )
						var testFile = getTempFile( getTempDirectory(), "image-exif-test", imageFormat );
						imageWrite ( variables.testImage, testFile );

						expect( ImagegetExifMetaData( testFile ) ).toBeStruct( "Can read ImageGetExifMetaData() with the format [#imageFormat#]" );
					} finally {
						if ( fileExists( testFile ) )
							fileDelete( testFile );
					}
				});

				it( title="test imageRead() with format: [#name#]",
						data={ imageFormat=_imageFormat },
						body=function( data ) {
					try {
						var imageFormat = data.imageFormat;
						// test if we can write a file in this image format (image format is based on file extension )
						var testFile = getTempFile( getTempDirectory(), "image-write-test", imageFormat );
{'fraction_non_alphanumeric': 0.13611023456400548, 'fraction_numerical': 0.003576312191017145, 'mean_word_length': 3.1922398589065257, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4988594', 'n_tokens_mistral': 3498, 'n_tokens_neox': 2783, 'n_words': 802}