function [imgary, fail] = load_image_array(img_file_ary, b_flip_ud, b_flip_lr)
	%% load the first image to find the size
	infilename  = img_file_ary{1};
	[~,~,ext]	= fileparts(infilename);
	
	is_raw12		= strcmpi(ext, '.raw12');
	Npages		= 1;
	
	if is_raw12
		Ni			= 1024;
		Nj			= 1024;
	else
		% get image info
		info		= imfinfo(infilename);
		Npages	= length(info);
		Ni			= info(1).Width;
		Nj			= info(1).Height;
	end
	
	%% allocate memory
	Nk				= length(img_file_ary);
	if Npages > 1 && Npages ~= Nk
		error('Number of pages in multipage image does not match number of sheets');
	end
	imgary		= zeros(Ni, Nj, Nk, 'single');

	%% load images
	for k = 1 : Nk
		infilename		= img_file_ary{k};
		page				= min(k, Npages);

		if is_raw12
			img			= imread_raw12(infilename, Ni, Nj);
			img			= fliplr(img);
		else
			img			= imread(infilename, page);
			img			= fliplr(img');	% this is the default manipulation which makes (1,1) correspond to (-Lx/2,-Ly/2)
		end

		if b_flip_ud
			img		= fliplr(img);		% counter-intuitive, but this is the right operation
		end
		if b_flip_lr
			img		= flipud(img);
		end

		imgary(:,:,k)	= single(img);
	end
	
	%% TODO: implement error checking
	fail			= false;
end