I need to convert column A to column B (without blank cells between the flag images) using a formula.
You can use formulas to access some types of images, but not all.
If the images were imported with Insert > Image in cell or
image() formulas, use one of these formulas to show the column without blanks:
=filter(A1:A, not(isblank(A1:A)), not(istext(A1:A)), not(len(A1:A)))
If the images were imported with Insert > Image over cells, they cannot be accessed with formulas.
Also note that some functions do not work well with images. For example, these formulas will not get the results you might expect:
=vlookup("*", A1:A, 1, false)
To detect whether a cell contains an image, use this formula:
=1 = not(isblank(A1)) * not(istext(A1)) * not(len(A1))