A percentage value on any element refers to a percentage if the size of its parent element.
In the first case the parent element is styled as a table-cell within a table.
In the second the parent element is the whole body of the page, so scales to 40% of the whole page.
So why does it not scale the same within the table?
By default tables are scaled to only accommodate their content. So the child element defines the size of the parent. But with the 40% you are trying to do the opposite, scale the child according to the parent, which should be scaled according to the child. This is a dependency loop, so cannot work. The result is the image does not scale above its native pixel size and the 40% scaling only occurs when the viewport is too small for the image to be native size.
To alter this you must change the default behaviour of the table styled element by defining a width for it, instead of letting its width be defined by its content.