detect edges of an image for crop it

Hi i have a lots of jpgs(more than 1000) that i need to crop but, they has not the same size and i need to crop it detecting the size of a rectangular region where the design are. the image are an autorization sheet that has the logo of my company at bottom of sheet and the design in the middle of the sheet i need reduce the size of the sheet to the right size of the design without the logo. I download the imagine Photo and i think that can do that with detect edges filter, but i have not idea how to use this application. Or, have you any suggestion.

TKU all

I have a question for you. Are the images placed in another document in an application or is the logo that you need to cut out of the picture in the jpeg itself?

I looked at the detect edges filter in the Imagine Photo application and I think it will be something similar to the Photoshop filter Find Edges where it outlines all edges in the image.

PreTech

I think we need more info to effectively help, but you may find the “Trim” function in PhotoShop to be useful as well, it really all depends on the images - and without seeing them I can’t say.

I found a solution for my problem, I will try to exlaplain this thread best.

Well I have 1000 images in jpg format, those images has a rectangular area where the design is placed, the same image have a logo in the botton. The task is: Cut the logo from the bottom it does not have problem because the logo is the las item on the bottom and allways have the same hieght, so i just need to use this instruction:

crop current document bounds {0 as pixels, 0 as pixels, image_w as pixels, (image_h - 300)as pixels} 

The best part comes when the image is cropped, there are white areas that i dont like arround of the rectangular area of the design. Finally!!!, I found a script that use the histogram Property of class Current Document of Photoshop’s applescript this property makes an array with all values of colors, when an area is white the array has all its values in 0’s but the last item is the value for white, this value allways is major than cero. This way, the script makes 4 selections, first from left to rigth wit loop that increments by 10 (pixels), the selection moves by 10 while the array has not a value > 0 in some item; and the same way for the other 3 sides of rectangle. Like this:

set el_folder to (choose folder) as string
set archivos to list folder el_folder as list

set cuenta to count every item in archivos

set f14 to "G4:F14:"

repeat with i from 2 to cuenta
	
	set imagen to el_folder & item i of archivos as alias
	
	tell application "Adobe Photoshop 7.0"
		
		activate
		set ruler units of settings to pixel units
		set codigo to f14 & items 1 thru 11 of item i of archivos as string
		
		set clean_f14 to "G4:F14" & codigo
		
		set Opciones to {class:JPEG save options, embed color profile:false, format options:standard, quality:12, scans:3}
		
		open imagen
		
		-- Crop the logo
		
		set image_w to width of current document as integer
		set image_h to (height of current document as integer)
		
		set new_h to (height of current document as integer) - 350
		crop current document bounds {0 as pixels, 0 as pixels, image_w as pixels, new_h as pixels}
		
		tell current document
			set rebace to 40
			-- Scan the left side until numero is true	
			repeat with j from 0 to image_w by 10
				
				
				select region {{0, 0}, {j + 10, 0}, {j + 10, image_h}, {0, image_h}}
				
				
				set x to histogram
				
				set pixeles to items 1 thru 255 of x as list
				set numero to some item in pixeles is not 0
				
				if numero then
					set a_x to j - rebace --> Takes the first value for the last crop instruction
					set a to 0
					exit repeat
				end if
				
				-- Scan the right side until numero is true		
				
			end repeat
			
			repeat with j from 0 to image_h by 10
				
				
				select region {{(image_w - j), 0}, {(image_w - j) - 10, 0}, {(image_w - j) - 10, image_h}, {(image_w - j), image_h}}
				
				set x to histogram
				
				set pixeles to items 1 thru 255 of x as list
				set numero to some item in pixeles is not 0
				
				if numero then
					set b_x to ((image_w - j) + rebace) --> Takes the 2nd value for the last crop instruction
					
					set j to 0
					exit repeat
				end if
				
			end repeat
			
			
			-- Scan the top side until numero is true		
			
			repeat with j from 0 to image_w by 10
				
				
				select region {{0, j}, {0, j + 10}, {image_w, j + 10}, {image_w, j}}
				
				
				
				set x to histogram
				
				set pixeles to items 1 thru 255 of x as list
				set numero to some item in pixeles is not 0
				
				if numero then
					set a_y to j - rebace --> Takes the 3rd value for the last crop instruction
					set j to 0
					exit repeat
				end if
			end repeat
			

			
			-- Scan the botton side until numero is true		
			repeat with j from 0 to image_h by 10
				
				set y to (new_h - j)
				
				
				select region {{0, y - 10}, {image_w, y - 10}, {image_w, new_h}, {0, new_h}}
				
				set x to histogram
				
				set pixeles to items 1 thru 255 of x as list
				set numero to some item in pixeles is not 0
				
				
				
				if numero then
					set b_y to y + rebace --> Takes the 4th value for the last crop instruction
					set j to 0
					exit repeat
				end if
				
			end repeat
			
			
			deselect
		end tell
		
		crop current document bounds {a_x as pixels, a_y as pixels, b_x as pixels, b_y as pixels}
		save current document in file codigo as JPEG with options Opciones appending lowercase extension with copying
		close current document without saving
		
	end tell
	
	
end repeat