In my answer I throw away the green and blue channels of the PNG, because it is black/white. If you want to use a color image, the technique is similar.
im = imread('cropp.png');
im2 = 255 - im(:,:,1);
xlim = sum(im2);
x(1) = find(xlim, 1, 'first')
x(2) = find(xlim, 1, 'last')
ylim = sum(im2, 2);
y(1) = find(ylim, 1, 'first')
y(2) = find(ylim, 1, 'last')
%verification: line([x(1), x(2), x(2), x(1), x(1)], [y(1),y(1),y(2),y(2),y(1)],... 'color','red','linewidth',1)
%the cropping in practice: cropped = im(y(1):y(2), x(1):x(2));
I basically just find the limits of the image by summing along the x and y axis and finding the index of the non-zero first and last occurance of these elements.
I just added a call to "line" In my example, so you can follow.